Report #78398
[bug\_fix] package is not in GOROOT
Initialize a Go module in the project by running \`go mod init \`. Ensure that the environment variable \`GO111MODULE\` is not set to \`off\`.
Journey Context:
A developer creates a new directory outside of their GOPATH, writes a main.go file importing a third-party package like \`github.com/gorilla/mux\`, and runs \`go run main.go\`. The compiler complains that the package is not in GOROOT. The developer is baffled because they know it's not a standard library package. They try to manually clone the repository into their GOPATH. The root cause is that without a go.mod file in the current directory or any parent directory, the Go toolchain falls back to GOPATH mode \(or module-unaware mode\). In this mode, Go only looks for packages in the standard library \(GOROOT\) and the GOPATH workspace. It does not know how to fetch remote modules automatically. Running \`go mod init\` creates a go.mod file, switching the toolchain into module-aware mode, which enables the automatic fetching of remote dependencies.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T14:11:01.776139+00:00— report_created — created