Upload debug symbols for Go
The Go SDK resolves stack traces in-process from the Go runtime, so captured frames already carry file names, line numbers, function names, and inlined calls. What they can't carry is your source code.
That's what uploading debug symbols adds. PostHog resolves the frames again against the exact build that crashed, so the UI can show the lines of code around each frame. It also classifies frames as app or library code from their real source paths, instead of guessing from the function name.
- posthog-go 1.22.0 or later, which records the instruction addresses and binary identity server-side symbolication needs. We recommend the latest version.
- hog, the PostHog CLI. We recommend keeping it up to date with
hog upgrade.
- 1
Install hog
Required - 2
Authenticate
RequiredLog in to PostHog. This opens your browser, where you approve the login:
TerminalIf posthog-cli is already logged in on this machine, import that login instead:
TerminalThese CI providers can upload with the job's OIDC token, so you don't store a personal API key in CI.
- Logged in with
hog auth login, run this once in the repository:
Terminal- An organization admin approves the request in PostHog.
- Add the
hostandprojectIdthat hog prints toposthog.json, and add the snippet it prints to the job.
In GitHub Actions, the job needs the
id-token: writepermission:YAMLRemove any personal API key from the job. A key wins over the OIDC token.
Set these environment variables in the job:
Environment variable Description Source HOG_HOSTThe PostHog host to connect to, such as https://eu.posthog.com[default: https://us.posthog.com]Project settings HOG_PROJECT_IDPostHog project ID Project settings HOG_PERSONAL_API_KEYPersonal API key with the error_tracking:writescopeAPI key settings hog reads only the
HOG_*names. The PostHog build plugins and upload scripts still pass the oldPOSTHOG_CLI_*names to hog for now, with a warning for each one. Ahogcommand you run yourself needs theHOG_*names. The migration guide lists each rename. - 3
Build with the right linker flags
RequiredGo embeds DWARF debug info in every binary by default. What you add on top depends on the platform.
On Linux, add a GNU build ID. That's the identifier PostHog uses to match stack frames to uploaded symbols, and Go doesn't emit one unless you ask:
TerminalOn macOS there's no build ID step, since every Mach-O binary carries a UUID. Instead, turn off DWARF compression. Go compresses debug info by default, and symbolication can't read the compressed form yet:
TerminalTwo flags to avoid:
-ldflags="-w"and-ldflags="-s"strip the DWARF entirely, and-trimpathrewrites the source paths that--include-sourcereads from. - 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 it doesn't need one. Universal (fat) binaries upload one symbol set per architecture slice. Windows isn't supported yet, so the SDK falls back to plain runtime-resolved frames there.Run this in the same pipeline that produces your production binary. Every build gets its own identity, so you need to re-upload for each 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. Uploads get bigger, so turn it on only if you want source context in the error tracking UI. It also means building without
-trimpath, since the CLI reads the sources off disk using the paths recorded at compile time. - 6
Optional: Upload from CI
OptionalIn CI, log in as the Authenticate step describes. For GitHub Actions, with the job's OIDC token:
YAMLIn other CI providers, set
HOG_PERSONAL_API_KEYandHOG_PROJECT_IDon the upload step only. The build itself doesn't need them.hog defaults to US Cloud. If you're on EU Cloud or self-hosted, also set
HOG_HOST(for examplehttps://eu.posthog.com), orhostinposthog.json.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 open the error tracking issues view. The stack trace should resolve against the uploaded symbols, with source context if you used
--include-source. Rebuilding changes the binary's identity, so upload again before you test.





