1
2
3
4
5 package imports
6
7 import (
8 "cmd/go/internal/cfg"
9 "sync"
10 )
11
12 var (
13 tags map[string]bool
14 tagsOnce sync.Once
15 )
16
17
18
19
20 func Tags() map[string]bool {
21 tagsOnce.Do(func() {
22 tags = loadTags()
23 })
24 return tags
25 }
26
27 func loadTags() map[string]bool {
28 tags := map[string]bool{
29 cfg.BuildContext.GOOS: true,
30 cfg.BuildContext.GOARCH: true,
31 cfg.BuildContext.Compiler: true,
32 }
33 if cfg.BuildContext.CgoEnabled {
34 tags["cgo"] = true
35 }
36 for _, tag := range cfg.BuildContext.BuildTags {
37 tags[tag] = true
38 }
39 for _, tag := range cfg.BuildContext.ToolTags {
40 tags[tag] = true
41 }
42 for _, tag := range cfg.BuildContext.ReleaseTags {
43 tags[tag] = true
44 }
45 return tags
46 }
47
48 var (
49 anyTags map[string]bool
50 anyTagsOnce sync.Once
51 )
52
53
54
55
56 func AnyTags() map[string]bool {
57 anyTagsOnce.Do(func() {
58 anyTags = map[string]bool{"*": true}
59 })
60 return anyTags
61 }
62
View as plain text