Skip to content

[go] Auto-detect bundler package name - #2452

Merged
SteveSandersonMS merged 2 commits into
github:mainfrom
qmuntal:go-bundler-package-name
Sep 1, 2026
Merged

SteveSandersonMS merged 2 commits into
github:mainfrom
qmuntal:go-bundler-package-name

Conversation

@qmuntal

@qmuntal qmuntal commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • auto-detect the destination Go package by parsing package declarations
  • ignore test files and previously generated bundler sources during detection
  • fall back to main with a warning when package detection fails

This 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

Copilot AI balanced review requested due to automatic review settings September 1, 2026 06:03
@qmuntal
qmuntal requested a review from a team as a code owner September 1, 2026 06:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 High severity

New issues introduced by this change (1)
Severity Finding
High severity 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 main with 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.

Comment thread go/cmd/bundler/main.go
@qmuntal

qmuntal commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

@copilot rebase

@qmuntal
qmuntal force-pushed the go-bundler-package-name branch from db34ebb to 8ff81bd Compare September 1, 2026 12:59
@SteveSandersonMS

Copy link
Copy Markdown
Contributor

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 SteveSandersonMS left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved. I validated the Go bundler non-main package scenario end-to-end, and the rebased branch is mergeable with passing checks.

@SteveSandersonMS
SteveSandersonMS added this pull request to the merge queue Sep 1, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Sep 1, 2026
@SteveSandersonMS
SteveSandersonMS added this pull request to the merge queue Sep 1, 2026
Merged via the queue into github:main with commit 7591560 Sep 1, 2026
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants