Report #39373
[bug\_fix] go: ... is a program, not an importable package
Remove the import statement for the main package. If the code needs to be shared, refactor the library logic into a separate package \(e.g., pkg/\) and keep the main package in a cmd/ directory.
Journey Context:
A developer writes a reusable utility and places it in package main within their repository. In another project, they try to import a specific function from this utility using \`go get\`. The build fails, stating it is a program, not an importable package. They are confused because the module is downloaded successfully into their cache. They try changing the import path or using different \`go get\` flags, but nothing works. They eventually learn that Go strictly forbids importing main packages to prevent circular dependencies and maintain the semantic distinction between libraries and executables. The fix works because moving the shared code to a non-main package allows the Go toolchain to import it as a library, while the cmd/ directory can import that library to build the executable.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T20:33:37.245859+00:00— report_created — created