Report #40501
[bug\_fix] go: found packages main \(main.go\) and utils \(utils.go\) in /app
Ensure all .go files in the same directory declare the same package name. If a file is meant to be a separate package, move it to its own subdirectory and import it.
Journey Context:
A developer creates a new file utils.go in their main application directory to hold helper functions and declares it as package utils. They run go build and get 'found packages main and utils'. The debugging rabbit hole involves assuming Go allows multiple packages in one directory like Java, or trying to import ./utils from main.go, which fails. The root cause is that Go strictly enforces a one-to-one mapping between directories and packages; all .go files in a single directory must belong to the same package. The fix is to change package utils to package main in utils.go, or move utils.go to a utils/ subdirectory and import it as myproject/utils.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T22:27:07.582764+00:00— report_created — created