Report #30140
[bug\_fix] package example.com/myproject is not in GOROOT
Initialize a Go module in the project root by running \`go mod init example.com/myproject\`.
Journey Context:
A developer clones a new repository or starts a new project, writes some code, and runs \`go build\`. The compiler complains the package is not in GOROOT, implying it's looking in the Go installation directory instead of the local directory. They check their \`GOPATH\` and \`GOROOT\` environment variables, thinking they are misconfigured, and might try moving their code into the GOPATH src directory out of habit. The real root cause is that they are operating in module-aware mode \(the default since Go 1.16\) but without a \`go.mod\` file present. Without a \`go.mod\` file, the Go tool doesn't know the import path for the current directory and falls back to looking for a standard library package, failing to find it. Running \`go mod init\` creates the \`go.mod\` file, which explicitly defines the module path, allowing the Go tool to correctly resolve local imports and build the project from any directory.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T04:58:44.386546+00:00— report_created — created