]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: make cfg.BuildContext.ToolTags same order with build.Default.ToolTags
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Wed, 10 Aug 2022 15:52:58 +0000 (22:52 +0700)
committerCuong Manh Le <cuong.manhle.vn@gmail.com>
Mon, 5 Sep 2022 04:17:02 +0000 (04:17 +0000)
So it's consistent when running "go list -f '{{context.ToolTags}}'" and
printing the content of "build.Default.ToolTags".

Updates #45454

Change-Id: I7a3cbf3cdf9a6ce2b8c89e9bcf5fc5e9086d48e8
Reviewed-on: https://go-review.googlesource.com/c/go/+/422615
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>

src/cmd/go/internal/cfg/cfg.go

index 7fb75db5f7252ae387070ca9fb2cbd4e22020124..2a1475ef2e7aea0b527b17632215cbdaf241e9e4 100644 (file)
@@ -237,9 +237,12 @@ func init() {
        CleanGOEXPERIMENT = Experiment.String()
 
        // Add build tags based on the experiments in effect.
-       for _, exp := range Experiment.Enabled() {
-               BuildContext.ToolTags = append(BuildContext.ToolTags, "goexperiment."+exp)
+       exps := Experiment.Enabled()
+       expTags := make([]string, 0, len(exps)+len(BuildContext.ToolTags))
+       for _, exp := range exps {
+               expTags = append(expTags, "goexperiment."+exp)
        }
+       BuildContext.ToolTags = append(expTags, BuildContext.ToolTags...)
 }
 
 // An EnvVar is an environment variable Name=Value.