Debian Codegraph @

cmd/bpf2go/flags.go

raw symbols SCIP
1 //go:build !windows
2
3 package main
4
5 import (
6 "flag"
7 "go/build/constraint"
8 )
9
10 // buildTags is a comma-separated list of build tags.
11 //
12 // This follows the pre-Go 1.17 syntax and is kept for compatibility reasons.
13 type buildTags struct {
14 Expr constraint.Expr
15 }
16
17 var _ flag.Value = (*buildTags)(nil)
18
19 func (bt *buildTags) String() string {
20 if bt.Expr == nil {
21 return ""
22 }
23
24 return (bt.Expr).String()
25 }
26
27 func (bt *buildTags) Set(value string) error {
28 ct, err := constraint.Parse("// +build " + value)
29 if err != nil {
30 return err
31 }
32
33 bt.Expr = ct
34 return nil
35 }
36
37 func andConstraints(x, y constraint.Expr) constraint.Expr {
38 if x == nil {
39 return y
40 }
41
42 if y == nil {
43 return x
44 }
45
46 return &constraint.AndExpr{X: x, Y: y}
47 }