1
2
3
4
5 package constraint_test
6
7 import (
8 "fmt"
9 "log"
10
11 "go/build/constraint"
12 )
13
14 func ExampleParse() {
15 expr, err := constraint.Parse("//go:build linux && (amd64 || arm64)")
16 if err != nil {
17 log.Fatal(err)
18 }
19
20 tagSets := []map[string]bool{
21 {"linux": true, "arm64": true},
22 {"linux": true, "amd64": true},
23 {"linux": true},
24 {"arm64": true},
25 }
26
27 fmt.Println(expr)
28 for _, tags := range tagSets {
29 fmt.Println(expr.Eval(func(tag string) bool {
30 return tags[tag]
31 }))
32 }
33
34
35
36
37
38
39
40 }
41
View as plain text