> For the complete documentation index, see [llms.txt](https://docs.opensoutheners.com/oss/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.opensoutheners.com/oss/lambdary/guides/go-functions.md).

# Go Functions

Run Go Lambda functions without building a bootstrap by hand.

A Go function needs no hand-built `bootstrap`. Lambdary builds it with `go build -tags lambda.norpc` every time the function starts, so hot reload rebuilds it too, and Go's build cache keeps an unchanged rebuild quick.

You need `go` on your `PATH`. The [Docker image](https://docs.opensoutheners.com/oss/lambdary/guides/docker-compose.md) carries one.

## One function per directory

A function directory with a `go.mod` and a `provided.*` runtime is built this way. Since a `go.mod` on its own already implies `provided.al2023`, this is enough:

```
my-functions/
  checksum/
    go.mod
    main.go
```

A function with a `Dockerfile` still builds from its `Dockerfile`.

## Many functions in one module

For one module holding many functions, list them in `lambdary.yml`:

```yaml
functions:                # replaces the directory scan when set
  ping:
    go: ./cmd/ping        # a Go main package, relative to root
  notify:
    go: ./cmd/notify
    timeout: 30           # any .lambda.yml key, inline
    url:
      path: /hooks/notify
  legacy:
    path: ./legacy-node   # an ordinary function directory
build:
  go:
    tags: [netgo]         # added after lambda.norpc
    ldflags: "-X main.version=dev"
```

Each entry sets exactly one of `go` or `path`, and the key is the function's name. Inline settings win over a `.lambda.yml` in that directory, which wins over `defaults:`. A `go:` entry runs on `provided.al2023` unless the entry or its `.lambda.yml` says otherwise.

See [Project Configuration](https://docs.opensoutheners.com/oss/lambdary/configuration/project-config.md#functions) for every rule.

## How builds work

* The build runs `go build` with `CGO_ENABLED=0` from the module that holds the package.
* The tags are `lambda.norpc`, then `build.go.tags`. `build.go.ldflags` is passed as `-ldflags`.
* The container backend builds for Linux on the function's `architectures` (`x86_64` by default). The process backend builds for your host.
* Binaries go to `.lambdary/build/`, never into your source tree.
* A failed build fails the function's start, with the tail of the compiler output.

## Reloads

Editing a function's own package reloads that function. Editing shared code elsewhere in the module, or `go.mod` / `go.sum`, reloads every function built from it.

## Published versions

[Publishing a version](https://docs.opensoutheners.com/oss/lambdary/guides/versions-and-aliases.md) of a Go function freezes the `bootstrap` built for the backend that would run it at that moment. See [Limitations](https://docs.opensoutheners.com/oss/lambdary/reference/limitations.md#go-functions) for what that means when you switch backends later.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.opensoutheners.com/oss/lambdary/guides/go-functions.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
