From 6ba2674ddc5373f261211ba5ebc38496dc660604 Mon Sep 17 00:00:00 2001 From: Zeke Lu Date: Thu, 25 Aug 2022 04:17:00 +0000 Subject: [PATCH] cmd/go/internal/imports: include ToolTags in the Tags map This fixes a regression introduced when the "race" mode tag was moved to the ToolTags field in CL 358539. Fixes #54468 Change-Id: I107771948a4fe9d743cc13d1c15f324212b08e03 GitHub-Last-Rev: d211e351ef3331f2c38b16d327d992a32ebbfe30 GitHub-Pull-Request: golang/go#54618 Reviewed-on: https://go-review.googlesource.com/c/go/+/425154 Reviewed-by: David Chase Auto-Submit: Bryan Mills Reviewed-by: Bryan Mills Run-TryBot: Bryan Mills TryBot-Result: Gopher Robot --- src/cmd/go/internal/imports/tags.go | 3 ++ src/cmd/go/testdata/script/test_race_tag.txt | 29 ++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 src/cmd/go/testdata/script/test_race_tag.txt diff --git a/src/cmd/go/internal/imports/tags.go b/src/cmd/go/internal/imports/tags.go index 01b448b9142..d1467b81b0b 100644 --- a/src/cmd/go/internal/imports/tags.go +++ b/src/cmd/go/internal/imports/tags.go @@ -36,6 +36,9 @@ func loadTags() map[string]bool { for _, tag := range cfg.BuildContext.BuildTags { tags[tag] = true } + for _, tag := range cfg.BuildContext.ToolTags { + tags[tag] = true + } for _, tag := range cfg.BuildContext.ReleaseTags { tags[tag] = true } diff --git a/src/cmd/go/testdata/script/test_race_tag.txt b/src/cmd/go/testdata/script/test_race_tag.txt new file mode 100644 index 00000000000..4b18ebc4549 --- /dev/null +++ b/src/cmd/go/testdata/script/test_race_tag.txt @@ -0,0 +1,29 @@ +# Tests Issue #54468 + +[short] skip 'links a test binary' +[!race] skip + +go mod tidy +go test -c -o=$devnull -race . + +! stderr 'cannot find package' + +-- go.mod -- +module testrace + +go 1.18 + +require rsc.io/sampler v1.0.0 +-- race_test.go -- +//go:build race + +package testrace + +import ( + "testing" + + _ "rsc.io/sampler" +) + +func TestRaceTag(t *testing.T) { +}