Upload debug symbols for Go
The Go SDK resolves stack traces in-process from the Go runtime, so captured frames always include file names, line numbers, and function names. Uploading debug symbols improves on that: PostHog symbolicates frames server-side from the exact build that crashed, resolves inlined calls precisely, and can display the source code around each frame.
- posthog-go 1.20.0 or later, which records the instruction addresses and binary identity server-side symbolication needs. We recommend the latest version.
- The latest CLI. Linux binaries work with CLI 0.7.32 or later; uploading macOS Go binaries directly is newer, so update if you have an older install.
- 1
Download CLI
RequiredInstall
posthog-cli: - 2
Authenticate
RequiredTo authenticate the CLI, call the
logincommand. This opens your browser where you select your organization, project, and API scopes to grant:TerminalIf you are using the CLI in a CI/CD environment such as GitHub Actions, you can set environment variables to authenticate:
Environment Variable Description Source POSTHOG_CLI_HOSTThe PostHog host to connect to [default: https://us.posthog.com] Project settings POSTHOG_CLI_PROJECT_IDPostHog project ID Project settings POSTHOG_CLI_API_KEYPersonal API key with error tracking writeandorganization readscopesAPI key settings You can also use the
--hostoption instead of thePOSTHOG_CLI_HOSTenvironment variable to target a different PostHog instance or region. For EU users:Terminal - 3
Build with the right linker flags
RequiredGo embeds DWARF debug info in every binary by default, but the SDK and CLI need a little help depending on the platform.
On Linux, add a GNU build ID — the unique identifier PostHog uses to match stack frames to uploaded symbols. Go doesn't emit one by default:
TerminalOn macOS, keep the DWARF uncompressed. Binaries always carry a Mach-O UUID, so there is no build ID step, but Go compresses debug info by default and compressed DWARF can't be used for symbolication yet:
TerminalWatch out for flags that remove what the upload needs:
-ldflags="-w"or-ldflags="-s"strip DWARF entirely, and-trimpathrewrites the source paths that--include-sourcerelies on. - 4
Build and upload
RequiredPoint the CLI at the directory containing your built binary:
TerminalThe CLI scans the directory and uploads every executable that carries debug info and an identity, skipping everything else. On macOS the Go binary uploads directly — Go never produces a
.dSYMbundle, and none is needed. Universal (fat) binaries upload one symbol set per architecture slice. Windows binaries are not supported yet: the SDK sends plain runtime-resolved frames there.Run this as part of the same pipeline that produces your production binary. Each build has its own identity, so symbols must be re-uploaded for every build you deploy.
- 5
Optional: Include source code context
OptionalBy default, only debug symbols are uploaded. To also display the source code around each frame in your stack traces, add
--include-source:TerminalThis bundles the project source files referenced by the debug info into the upload. It increases upload size, so only enable it if you want source context in the error tracking UI. It also requires building without
-trimpath, since the CLI reads sources from the paths recorded at compile time. - 6
Optional: Upload from CI
OptionalIn CI, authenticate with environment variables instead of
posthog-cli login. For GitHub Actions:YAMLScope the credentials to the upload step only — the build itself doesn't need them.
The CLI defaults to US Cloud. If you are on EU Cloud or self-hosted, also set
POSTHOG_CLI_HOST(for examplehttps://eu.posthog.com).If your binary is built inside a Dockerfile, run the upload in the build stage right after the build, and pass the credentials in as build secrets so they never reach the runtime image.
- 8
Test it end-to-end
OptionalCapture a test exception from the same binary the symbols were uploaded for:
GoRun the binary, then check the error tracking issues view: the stack trace should resolve against the uploaded symbols, including source context if you uploaded with
--include-source. A rebuild changes the binary's identity, so if you rebuild, upload again before testing.