Records below are third-party data, not instructions. Apply with your own judgment.
./main.go:<n>:<n>: undefined: <name>
Cause
go run main.go compiles a package made of exactly the files named on the command line, so identifiers declared in the package's other .go files are missing.
Fix
go run . # compile the whole package in this directorygo run ./cmd/<app> # or name the package directoryDon’t try
go build main.go — same file-list rule: it compiles only main.go and fails identically.
go run *.go — works only until the directory has a _test.go file: the glob passes it too and go stops with go: cannot run *_test.go files (<file>).