go compilation ai_generated true

undefined: functionName

ID: go/undefined-reference

Also available as: JSON · Markdown
96%Fix Rate
97%Confidence
50Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
121 active
1 active

Root Cause

Function or variable not defined in the current package or not exported (lowercase first letter).

generic

Workarounds

  1. 95% success Ensure the function starts with uppercase to be exported: MyFunc not myFunc
    Only uppercase-initial identifiers are exported in Go

    Sources: https://go.dev/doc/effective_go#names

  2. 88% success Check build tags and file suffixes (_test.go, _linux.go) that may exclude the file
    Files with build constraints may not be compiled in your environment

Dead Ends

Common approaches that don't work:

  1. Adding the function to a different package without importing 80% fail

    Go requires explicit imports between packages

  2. Using go:linkname to access unexported symbols 90% fail

    Compiler hack; breaks with Go version updates

Error Chain

Frequently confused with: