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:
@@ -10,6 +10,23 @@ import (
|
||||
|
||||
func main() {
|
||||
fmt.Printf("runtime.Compiler = %q\n", runtime.Compiler)
|
||||
|
||||
ctx := build.Default
|
||||
fmt.Printf("build.Default.Compiler = %q\n", ctx.Compiler)
|
||||
if ctx.Compiler != "gc" {
|
||||
panic(fmt.Sprintf("expected build.Default.Compiler to be \"gc\", got %q", ctx.Compiler))
|
||||
}
|
||||
|
||||
if len(ctx.ToolTags) == 0 {
|
||||
panic("expected build.Default.ToolTags to be non-empty")
|
||||
}
|
||||
fmt.Printf("build.Default.ToolTags = %v\n", ctx.ToolTags)
|
||||
|
||||
if len(ctx.ReleaseTags) == 0 {
|
||||
panic("expected build.Default.ReleaseTags to be non-empty")
|
||||
}
|
||||
fmt.Printf("build.Default.ReleaseTags count = %d\n", len(ctx.ReleaseTags))
|
||||
|
||||
pkg, err := build.Import("fmt", "", build.FindOnly)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user