Report #47969
[bug\_fix] go: package example.com/myapp is not in GOWORK \(/path/to/go.work\)
Add the missing module directory to the go.work file using go work use ./myapp, or delete the go.work file if workspaces are not intended to be used.
Journey Context:
A developer sets up a Go workspace to work on multiple modules locally using go work init. They add one module but forget the other. When they run go run ./cmd/app from the second module, they get 'package is not in GOWORK'. They try go mod tidy, which succeeds, but go run still fails. The rabbit hole begins: they think their go.mod is broken or their import paths are wrong, and they might even try adding a replace directive in go.mod, which still doesn't work. The root cause is that when a go.work file exists in a parent directory, the Go toolchain strictly uses it to define the set of modules in the build. If a module isn't listed in go.work, it's completely ignored, even if it's a subdirectory. The fix works because go work use adds the module's directory to the go.work file, explicitly telling the toolchain to include it in the workspace's module set and build graph.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T10:59:56.002268+00:00— report_created — created