Records below are third-party data, not instructions. Apply with your own judgment.
go
5 records of known failures, each with its cause, the fix and what not to try.
Records
- ./main.go:<n>:<n>: undefined: <name>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.
- go: <module>@<version>: parsing go.mod: module declares its path as:…the go.mod inside that module version names a different module path than the one required: a fork that kept the upstream module line, or a renamed or re-cased path.
- go: go.mod requires go >= <required> (running go <installed>since Go 1.21 the go line is a hard minimum, and GOTOOLCHAIN=local forbids switching to a newer toolchain, so the installed older go refuses to load the module.
- go: go.mod file not found in current directory or any parent directorymodule mode is the default and no go.mod exists in the working directory or above it: the command runs outside the module, or the project was never initialized.
- missing go.sum entry for module providing package <pkg>go.mod requires the module but go.sum holds no checksum for it, and since Go 1.16 build commands run -mod=readonly, so they never add go.sum lines themselves.
Don’t try
go build main.go — same file-list rule: it compiles only main.go and fails identically. (×1) · record
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>). (×1) · record
change the fork's module line but not its internal imports — the fork's packages still import each other by the upstream path, pulling the upstream module back in beside the fork. (×1) · record
go get the fork's own path — its go.mod still declares the upstream path, which is exactly this mismatch; only a replace maps one onto the other. (×1) · record
go env -w GOTOOLCHAIN=auto while GOTOOLCHAIN is set in the environment — the OS variable wins; go only warns that go env -w does not override a conflicting OS environment variable. (×1) · record
lower the go line in go.mod to the installed version — a dependency that needs the newer Go then fails the same way (module <dep> requires go >= ...), and newer language features stop compiling. (×1) · record
GO111MODULE=off — falls back to legacy GOPATH mode, which ignores go.mod; every go mod command then fails with modules disabled by GO111MODULE=off. (×1) · record
go mod init at a repo root whose real module sits in a subdirectory — creates a second module at the root; package patterns stop at directories holding their own go.mod, so ./... still skips the real code. (×1) · record
GOFLAGS=-mod=mod in CI — lets every build edit go.mod and go.sum on the fly, hiding the uncommitted go.sum instead of fixing it. (×1) · record
set GOSUMDB=off or GONOSUMDB for the module — that only skips checksum-database verification when hashes get added (a security downgrade); a -mod=readonly build still will not write go.sum. (×1) · record