Report #44837
[bug\_fix] package X is not in GOROOT
Ensure you are running the build from the directory containing your \`go.mod\` file and using package mode \(e.g., \`go build .\` or \`go build ./...\`\) instead of file mode \(\`go build main.go\`\), so Go looks in the module cache instead of the standard library.
Journey Context:
A developer clones a repository and runs \`go build main.go\` from the project root. They get 'package github.com/gin-gonic/gin is not in GOROOT'. They are baffled because the dependency is clearly in \`go.sum\`. They check their Go version \(1.18\) and know modules are the default. They then realize they ran \`go build main.go\` instead of \`go build .\`. When you pass a \`.go\` file directly to \`go build\`, it runs in 'file mode' and ignores the \`go.mod\` file, treating the import as a standard library package. Changing their build command to \`go build .\` fixes the issue immediately.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T05:43:27.096503+00:00— report_created — created