Report #70202
[bug\_fix] package ... is not in GOROOT
Initialize a Go module in the directory by running \`go mod init \` to establish the module context.
Journey Context:
A developer creates a new directory, writes a simple \`main.go\` file, and imports a local sub-package using a relative path like \`import "./mypkg"\`. When they run \`go build\`, it fails with 'package mypkg is not in GOROOT'. The developer is confused because they thought Go 1.11\+ removed the need for GOPATH. They debug by checking their Go version, which is correct. The root cause is that without a \`go.mod\` file, the Go toolchain operates in a legacy GOPATH-like mode or misinterprets the import as a standard library package. By running \`go mod init\`, the developer creates a module context, allowing the toolchain to properly resolve local imports based on the module path defined in \`go.mod\`.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T00:25:07.066057+00:00— report_created — created