[go] Auto-detect bundler package name - #2452
Conversation
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Detection must respect target-specific filenames and build constraints to avoid generating an invalid package declaration.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review tier: Balanced
Findings: 1
New issues introduced by this change (1)
| Severity | Finding |
|---|---|
go/cmd/bundler/main.go — Package detection currently parses every .go file, including files excluded for the requested… |
What changed in this PR
Adds destination package auto-detection for generated Go bundler sources.
Changes:
- Parses package declarations while excluding tests and generated files.
- Falls back to
mainwith a warning. - Adds detection tests.
| File | Description |
|---|---|
go/cmd/bundler/main.go |
Implements package detection and uses it during generation. |
go/cmd/bundler/main_test.go |
Tests detection and fallback behavior. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
@copilot rebase |
db34ebb to
8ff81bd
Compare
|
Thanks for this improvement — I validated the non-main package scenario end-to-end and it works as intended. Scope is appropriately Go-specific, and this looks good to merge. The remaining issue was only the rebase conflict with main, which now appears resolved. |
SteveSandersonMS
left a comment
There was a problem hiding this comment.
Approved. I validated the Go bundler non-main package scenario end-to-end, and the rebased branch is mergeable with passing checks.

Summary
mainwith a warning when package detection failsThis supports use cases where the Copilot integration happens in a non-main package, ensuring the generated embed sources use that package name.
Testing
go test ./cmd/bundler