Skip to content
Latchkey

Go "undefined: X" build error - Fix in CI

The compiler hit a name with no declaration in scope. The symbol is misspelled, unimported, in another package, or excluded by a build constraint.

What this error means

A build fails with undefined: SomeFunc or undefined: pkg.Thing. The same code may compile locally when a file the symbol lives in is included by a build tag that CI excludes.

go
./handler.go:21:9: undefined: computeChecksum
./handler.go:42:14: undefined: util.Helper

Common causes

Missing import or wrong package qualifier

The symbol lives in a package that is not imported, or is referenced without its package prefix.

Typo or removed declaration

The identifier is misspelled, or the function/variable was deleted or renamed.

Excluded by a build constraint

The file defining the symbol has a build tag that CI does not set, so it is omitted from the build.

How to fix it

Add the import and correct the name

  1. Import the package that declares the symbol and qualify it correctly.
  2. Fix any typo against the actual declaration.
Terminal
go build ./...
go vet ./...

Check build tags

  1. Confirm the file with the symbol is not gated behind a tag CI omits.
  2. Build with the same GOOS/GOARCH/tags as CI to reproduce.
Terminal
go build -tags integration ./...

How to prevent it

  • Run go build ./... and go vet ./... before pushing.
  • Keep build tags consistent between local and CI.
  • Let your editor flag undefined symbols as you type.

Related guides

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