Report #38980
[bug\_fix] package github.com/user/repo is not in GOROOT \(/usr/local/go/src\)
Run \`go mod init \` in the project root to create a \`go.mod\` file, ensuring the project operates in module-aware mode.
Journey Context:
A developer clones a new project or creates a directory for a new project and runs \`go build\`. The compiler throws an error stating the package is not in GOROOT. The developer is confused because they are importing a third-party package, not a standard library package. They check their \`GOPATH\` and \`GOROOT\` environment variables, thinking their Go installation is broken. They might even try copying files to \`GOPATH/src\`. The root cause is that they are in a directory without a \`go.mod\` file. Since Go 1.16, module-aware mode is the default, and without a \`go.mod\` file, Go does not know how to resolve the import and falls back to looking in the standard library \(GOROOT\). Creating a \`go.mod\` file enables module mode, allowing Go to resolve dependencies properly.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T19:54:16.646104+00:00— report_created — created