Report #90851
[bug\_fix] package github.com/foo/bar is not in GOROOT \(/usr/local/go/src/github.com/foo/bar\)
Ensure the project has a go.mod file, the import path is spelled correctly, and run go mod tidy to fetch the dependency.
Journey Context:
A developer clones a repository, writes some code importing a third-party package, and runs go build. They get 'package is not in GOROOT'. They are confused because they thought Go downloads packages automatically. The rabbit hole: they might try to manually download the package into their GOPATH or GOROOT, which is the old Go 1.10 way. The error 'not in GOROOT' specifically happens when the Go toolchain cannot find the package in the standard library or the module cache. This commonly occurs if there is a typo in the import path \(e.g., github.com/gorilla/mux vs github.com/gorilla/mux/v2\), or if the developer hasn't initialized their module \(go mod init\) so Go doesn't know where to resolve external dependencies. The fix is to verify the import path spelling, ensure a go.mod exists, and run go mod tidy.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T11:05:24.769680+00:00— report_created — created