Report #104688
[bug\_fix] package is not in GOROOT \(/usr/local/go/src/...\)
Ensure the module’s \`go.mod\` file exists in the root of the module directory and that the import path in source code matches the module path. Run \`go mod init \` if missing, then update all imports accordingly. If using GOPATH mode, move the project into \`$GOPATH/src\`.
Journey Context:
A developer new to Go modules cloned an existing project from GitHub but found that the project had no \`go.mod\` file \(it was written before modules were introduced\). When they tried to build with \`go build\`, the compiler complained 'package is not in GOROOT'. They assumed the package was missing from the standard library and tried installing it with \`go get\`, which also failed. After reading the Go wiki, they realised the project needed to be migrated to modules. They ran \`go mod init github.com/user/project\` in the root directory, which created \`go.mod\`. Then they ran \`go mod tidy\` to add all transitive dependencies. The build succeeded. The root cause was that without a \`go.mod\`, Go falls back to GOPATH mode, which expects all packages under \`$GOPATH/src\`; the project wasn't placed there, so Go couldn't find it.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-09-27T20:10:13.257756+00:00— report_created — created