Skip to content
Latchkey

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.Pinner

Common 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

  1. 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.mod

Gate newer APIs behind a build tag

  1. 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 pkg

How to prevent it

  • Use go-version-file: go.mod so 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

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →