Report #14039
[bug\_fix] package is not in GOROOT \(/usr/local/go/src/\)
Initialize the project as a Go module by running \`go mod init \` in the project root.
Journey Context:
A developer new to Go writes a script, imports a third-party package like \`github.com/spf13/cobra\`, and runs \`go run main.go\`. The compiler complains the package is not in GOROOT. The developer checks their GOPATH and GOROOT environment variables, thinking their installation is broken, and wastes time reinstalling Go. The actual issue is that they are running the code outside of a Go module \(no go.mod file exists in the directory or any parent\). Without a go.mod, the go command runs in GOPATH mode or legacy mode, where it only looks for packages in the standard library \(GOROOT\) or the GOPATH src folder. Running \`go mod init\` enables module-aware mode, allowing the toolchain to fetch and resolve remote dependencies properly.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T20:25:26.418119+00:00— report_created — created