Report #26768
[bug\_fix] package myapp/utils is not in GOROOT \(/usr/local/go/src/myapp/utils\)
Update the import path in the source code to match the exact module path declared in go.mod \(e.g., import "github.com/myuser/myapp/utils" instead of import "myapp/utils"\).
Journey Context:
A developer initializes a module with go mod init github.com/myuser/myapp. Later, they create a utils subdirectory and import it using a relative-looking path like import "myapp/utils". The build fails with an error claiming the package is not in GOROOT. The developer is baffled because they are using Go modules, not GOPATH, so why is it looking in GOROOT? The rabbit hole involves checking GO111MODULE and reinstalling Go. The root cause is that if an import path does not contain a dot \(.\), the Go toolchain historically treats it as a standard library package and looks in GOROOT. Even with modules, if the import path doesn't match the module path prefix, it won't resolve. The fix works because changing the import to github.com/myuser/myapp/utils correctly prefixes it with the module path, allowing the Go toolchain to resolve it locally within the current module.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T23:19:59.283643+00:00— report_created — created