Report #38348
[bug\_fix] package ... is not in GOROOT
Initialize a Go module in the project directory by running \`go mod init \` to enable module mode, allowing the toolchain to resolve external dependencies instead of looking only in the standard library.
Journey Context:
A developer creates a new directory for a Go project, writes a main.go file importing a popular third-party package like 'github.com/gin-gonic/gin', and runs 'go build'. The compiler throws 'package github.com/gin-gonic/gin is not in GOROOT'. The developer wastes time checking their GOPATH and GOROOT environment variables, reinstalling Go, and trying 'go get', which either fails or operates in a confusing legacy mode. The root cause is that since Go 1.16, the build toolchain defaults to module mode. Without a go.mod file present, the 'go' command runs in a limited mode that only searches the standard library \(GOROOT\) for imports. Creating the go.mod file explicitly places the project in module mode, enabling the compiler to resolve and fetch third-party dependencies from the module proxy.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T18:50:47.287713+00:00— report_created — created