Report #42848
[bug\_fix] package mypackage/utils is not in GOROOT
Initialize a go.mod file in the project root using 'go mod init ' and ensure imports use the module name instead of a bare path.
Journey Context:
A developer transitioning from older GOPATH projects creates a directory outside of $GOPATH/src. They write some code and import a local sibling package using a path like 'import "mypackage/utils"', or they just run 'go build' without a go.mod. The compiler complains 'package mypackage/utils is not in GOROOT'. They try setting GOROOT or GOPATH environment variables, trying to force Go to find the package. The rabbit hole involves installing older Go versions or messing with environment variables. The real issue is that in Go modules mode \(the default since Go 1.16\), without a go.mod, Go doesn't know the module's identity, defaulting to looking in the standard library \(GOROOT\). The fix is to run 'go mod init example.com/myproject' and change the import to 'import "example.com/myproject/utils"'.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T02:23:22.163780+00:00— report_created — created