Report #72117
[bug\_fix] go: import github.com/example/project/cmd/server: is a program, not an importable package
Remove the import of the \`main\` package. If you need to use shared logic, extract it into a separate library package within the module and import that instead.
Journey Context:
A developer wants to use some utility functions from another project's \`main\` package. They add \`import "github.com/example/project/cmd/server"\` to their code. The build immediately fails, stating it's a program, not an importable package. The rabbit hole: the developer tries to alias the import or change the package name in the source file, but the Go compiler strictly forbids importing a package that contains a \`main\` function. They wonder why Go cares, since it's just code. The fix works because Go's compilation model requires \`main\` packages to be the root of an executable binary and forbids them from being linked as libraries. Extracting the logic into a non-main package allows it to be imported cleanly.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T03:37:52.485383+00:00— report_created — created