Report #25174
[bug\_fix] package XXX is not in GOROOT
Initialize a Go module in the project using \`go mod init \` if not already using modules, or correct the typo in the import path if modules are already in use.
Journey Context:
A developer clones an older repository or starts a new project inside their \`GOPATH/src\` directory. They try to build it using \`go build ./...\` and get this error for a third-party dependency. The rabbit hole: they check their \`GOPATH\`, they run \`go get\`, they verify their Go installation \(\`GOROOT\`\). Everything seems correct. They don't realize that starting with Go 1.16, \`go build\` defaults to module mode \(\`GO111MODULE=on\`\), even inside \`GOPATH\`. Since there's no \`go.mod\` file, the Go toolchain thinks the import is a standard library package and looks only in \`GOROOT\`. The fix works because \`go mod init\` creates a \`go.mod\` file, explicitly telling the Go toolchain to treat the project as a module and resolve imports via the module proxy/cache rather than just the standard library.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T20:39:42.177955+00:00— report_created — created