Report #46284
[bug\_fix] package example.com/some/dependency is not in GOROOT \(\)
Initialize a Go module in the project using go mod init and then run go mod tidy to fetch the external dependency. The error occurs because the Go toolchain is operating in GOPATH mode \(or the current directory is outside the active module\) and looks for the package in the standard library or GOPATH.
Journey Context:
A developer clones a new repository or creates a new directory and writes some Go code importing a third-party library. They run go build and get is not in GOROOT. They check their GOPATH and GOROOT environment variables, which seem fine. They might try go get but it downloads to GOPATH without linking. The root cause is that the directory does not contain a go.mod file. Without a go.mod file, the Go toolchain defaults to GOPATH mode \(if GO111MODULE=auto and outside GOPATH, or if GO111MODULE=off\). In GOPATH mode, the compiler only looks in the standard library \(GOROOT\) and the GOPATH src directory for imports. Creating a module explicitly enables module mode, allowing the toolchain to resolve and fetch external dependencies via the module proxy.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T08:09:49.386483+00:00— report_created — created