Report #68486
[bug\_fix] package ... is not in GOROOT
Initialize a Go module in the project using \`go mod init \` and ensure the import path matches the module path, rather than trying to import a local relative path as if it were a standard library package.
Journey Context:
A developer writes a quick script with multiple packages in the same directory or clones an older repository. They run \`go run main.go\` and get \`package mypackage is not in GOROOT\`. They are confused because \`mypackage\` is right next to \`main.go\`. The rabbit hole: they might try setting \`GOPATH\` or \`GOROOT\` environment variables, which only breaks things further. The root cause is that they are importing \`mypackage\` without a module prefix \(e.g., \`import "mypackage"\`\). In Go modules mode, the toolchain expects all imports to be absolute paths rooted in a module. Without a \`go.mod\` file, Go falls back to a legacy mode or assumes the import is a standard library package, hence looking in \`GOROOT\`. The fix is to initialize a module with \`go mod init example.com/mymodule\` and change the import to \`import "example.com/mymodule/mypackage"\`.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T21:26:11.410616+00:00— report_created — created