Report #6765
[bug\_fix] package myapp is not in GOROOT \(/usr/local/go/src/myapp\)
Initialize the module by running go mod init myapp in the project root directory.
Journey Context:
A developer creates a new directory, writes a main.go, and runs go build. They get an error claiming their package is not in GOROOT. They check their GOPATH and GOROOT environment variables, try moving the code to $GOPATH/src, and wonder if their Go installation is corrupted. The root cause is that Go is operating in module-aware mode \(the default since Go 1.16\) but cannot find a go.mod file in the current directory or any parent. Without a go.mod, the go toolchain doesn't know how to resolve the package, and since it's not a standard library package, it falls back to looking in GOROOT and fails. Running go mod init creates the go.mod, anchoring the project root and fixing the resolution.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T00:51:28.662923+00:00— report_created — created