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.HelperCommon 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
- Import the package that declares the symbol and qualify it correctly.
- Fix any typo against the actual declaration.
Terminal
go build ./...
go vet ./...Check build tags
- Confirm the file with the symbol is not gated behind a tag CI omits.
- Build with the same GOOS/GOARCH/tags as CI to reproduce.
Terminal
go build -tags integration ./...How to prevent it
- Run
go build ./...andgo vet ./...before pushing. - Keep build tags consistent between local and CI.
- Let your editor flag undefined symbols as you type.
Related guides
Go "imported and not used" build error - Fix in CIFix Go "imported and not used" in CI - Go treats unused imports as compile errors. Remove the import or use i…
Go "build constraints exclude all Go files" - Fix in CIFix Go "build constraints exclude all Go files" in CI - every file in the package is filtered out by build ta…
Go "missing return at end of function" - Fix in CIFix Go "missing return at end of function" in CI - a function with a return type has a path that does not ret…