Report #59734
[bug\_fix] package is not in GOROOT
Initialize a Go module in the project directory by running go mod init , which enables module mode and allows the toolchain to resolve external dependencies.
Journey Context:
A developer starts a new Go project in an empty directory. They write a main.go file that imports a popular third-party router like github.com/gin-gonic/gin. When they run go run main.go, the compiler complains that the package is not in GOROOT. The developer is baffled, thinking Go should just download the package. The root cause is that starting in Go 1.16, module-aware mode is the default, but it requires a go.mod file to function. Without a go.mod file, the Go toolchain falls back to a legacy mode where it only looks for packages in the standard library \(GOROOT\) and the GOPATH workspace. By running go mod init, the developer creates a go.mod file, fully activating the module system, which allows the go command to fetch remote dependencies over the network.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T06:45:14.696478+00:00— report_created — created