Report #69770
[bug\_fix] package example.com/myapp is not in GOROOT \(/usr/local/go/src/example.com/myapp\)
Enable Go modules by running \`go mod init example.com/myapp\` in the project root, or ensure GO111MODULE is not set to 'off'. If using a multi-module repository, ensure the directory is included in a go.work file.
Journey Context:
A developer clones a repository and tries to run \`go build\`. They get an error saying the package is not in GOROOT. They check their GOPATH and GOROOT environment variables, which look fine. They notice there is no go.mod file in the root directory. Because there is no go.mod, Go falls back to GOPATH mode \(or fails if outside GOPATH\), looking for the package in the standard library or GOPATH src. They run \`go mod init example.com/myapp\` to create the go.mod file, and the build succeeds. The fix works because Go modules are the default, but without a go.mod file, the Go toolchain cannot determine the module root and reverts to legacy GOPATH resolution, failing to find the local package.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T23:35:44.543968+00:00— report_created — created