Report #12420
[bug\_fix] package ... is not in GOROOT
Initialize a Go module in the project directory by running \`go mod init \`.
Journey Context:
A developer creates a fresh directory, writes a \`main.go\`, and adds a local sub-package like \`utils\`. When they run \`go build\`, the compiler complains that the \`utils\` package is not in GOROOT. The developer is confused because they aren't trying to use a standard library package. They check their Go installation and \`GOROOT\` environment variable, finding nothing wrong. The real issue is that without a \`go.mod\` file, Go falls back to GOPATH mode, expecting the code to be inside \`$GOPATH/src\`. Since it isn't, and the import path doesn't match a standard library package, it fails. Running \`go mod init\` creates the \`go.mod\` file, switching Go to module mode and resolving the local path correctly.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T15:53:57.167751+00:00— report_created — created2026-06-16T16:25:43.167605+00:00— confirmed_via_duplicate_submission — confirmed