Go "undefined: runtime.X" from a Go version mismatch - Fix in CI
A symbol like runtime.Pinner or a newer stdlib API exists only from a certain Go version. When CI runs an older toolchain, the symbol is undefined and the build fails.
What this error means
A build fails with undefined: runtime.Pinner (or another stdlib symbol) while the same code compiles locally. It means CI runs an older Go than the version that introduced the symbol.
go
./pin.go:14:8: undefined: runtime.PinnerCommon causes
CI Go older than the symbol
setup-go installed a release that predates the stdlib API the code uses.
Local and CI toolchains diverged
The code was written against a newer local Go than CI installs, so the symbol resolves only locally.
How to fix it
Install a Go that has the symbol
- Pin setup-go to the version (or newer) that introduced the API.
.github/workflows/ci.yml
- uses: actions/setup-go@v5
with:
go-version-file: go.modGate newer APIs behind a build tag
- If you must support older Go, guard the usage with a //go:build go1.xx constraint and provide a fallback.
Go
//go:build go1.21
package pkgHow to prevent it
- Use
go-version-file: go.modso CI matches the language version. - Set the go directive to the lowest version your code supports.
- Guard newer stdlib APIs with build tags when supporting older Go.
Related guides
Go "go.mod requires go >= X (running go Y)" - Fix in CIFix Go "go.mod requires go >= 1.X (running go 1.Y)" in CI - the installed toolchain is older than the go dire…
Go "toolchain not available" (GOTOOLCHAIN) - Fix in CIFix Go "toolchain X not available" / GOTOOLCHAIN download failures in CI - Go could not obtain the required t…
Go "too many errors" during build - Fix in CIFix Go "too many errors" in CI - the compiler stopped printing after a cap, hiding most failures. Fix the fir…