Report #66185
[bug\_fix] go: package ... is not in GOROOT
Run go mod init in the project root to create a go.mod file, and ensure local imports match the new module path.
Journey Context:
A developer creates a new directory myproject and writes a main.go that imports a local package myproject/utils. They run go build and get 'package myproject/utils is not in GOROOT'. They expect Go to automatically resolve local directories relative to the current working directory, similar to older GOPATH behavior or scripting languages. The root cause is that without a go.mod file, the Go build system operates in a degraded mode and assumes the import path is relative to the GOROOT \(standard library\) or legacy GOPATH. Because GOPATH mode is deprecated and disabled by default in Go 1.16\+, it fails to find the package. The fix works because running go mod init creates a go.mod that defines the current module's path, allowing the Go toolchain to correctly resolve myproject/utils as a local package within the newly defined module.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T17:34:22.735305+00:00— report_created — created