Report #45170
[bug\_fix] found packages \(pkg\_a\) and \(pkg\_b\) in ...
Ensure all .go files in a single directory have the exact same 'package' declaration. Test files must use 'package foo\_test' \(external test package\) or 'package foo' \(internal\), but cannot introduce a new non-test package name in the same directory.
Journey Context:
A developer adds a new utility file 'utils.go' to an existing package directory and accidentally types 'package utils' instead of 'package main'. They run 'go build' and get 'found packages main and utils'. They mistakenly think Go allows multiple packages in a directory like Java or Python. They try renaming the file, moving it to a subdirectory, but leave a stray .go file with the wrong package name. They spend hours checking their GOPATH and module setup, assuming the build system is caching old files. The fix works because Go's compilation unit is the directory \(package\), not the single file. All files in a directory are compiled together, so they must belong to the exact same package namespace. Correcting the package declaration aligns the file with the directory's package identity.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T06:17:20.697569+00:00— report_created — created