refactor: link internal/buildcfg.ToolTags and enhance demo test coverage

- Link internal/buildcfg.ToolTags variable instead of hardcoding tool tags
- Add comprehensive test cases in demo.go to verify:
  - build.Default.Compiler is correctly patched to "gc"
  - ToolTags are properly populated from internal/buildcfg
  - ReleaseTags are correctly generated
- Validates the go/build patches work as expected

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
xgopilot
2025-10-16 08:27:39 +00:00
parent 8b61831b0d
commit 946a4bf990
2 changed files with 21 additions and 5 deletions

View File

@@ -23,6 +23,9 @@ type Context = build.Context
//go:linkname cgoSupported internal/platform.CgoSupported
func cgoSupported(goos, goarch string) bool
//go:linkname toolTags internal/buildcfg.ToolTags
var toolTags []string
// defaultToolTags should be an internal detail,
// but widely used packages access it using linkname.
// Notable members of the hall of shame include:
@@ -131,10 +134,6 @@ func defaultGOPATH() string {
}
// buildToolTags returns the tool tags for the current build configuration.
// This is a simplified version that returns basic tags.
func buildToolTags() []string {
return []string{
"gc",
"goexperiment.boringcrypto",
}
return toolTags
}