github.com/amarpal/go-tools@v0.0.0-20240422043104-40142f59f616/knowledge/arg.go (about)

     1  package knowledge
     2  
     3  var Args = map[string]int{
     4  	"(*sync.Pool).Put.x":                     0,
     5  	"(*text/template.Template).Parse.text":   0,
     6  	"(io.Seeker).Seek.offset":                0,
     7  	"(time.Time).Sub.u":                      0,
     8  	"append.elems":                           1,
     9  	"append.slice":                           0,
    10  	"bytes.Equal.a":                          0,
    11  	"bytes.Equal.b":                          1,
    12  	"encoding/ascii85.Encode.dst":            0,
    13  	"encoding/ascii85.Encode.src":            1,
    14  	"(*encoding/base32.Encoding).Encode.dst": 0,
    15  	"(*encoding/base32.Encoding).Encode.src": 1,
    16  	"(*encoding/base64.Encoding).Encode.dst": 0,
    17  	"(*encoding/base64.Encoding).Encode.src": 1,
    18  	"encoding/binary.Write.data":             2,
    19  	"encoding/hex.Encode.dst":                0,
    20  	"encoding/hex.Encode.src":                1,
    21  	"(*encoding/json.Decoder).Decode.v":      0,
    22  	"(*encoding/json.Encoder).Encode.v":      0,
    23  	"(*encoding/xml.Decoder).Decode.v":       0,
    24  	"(*encoding/xml.Encoder).Encode.v":       0,
    25  	"errors.New.text":                        0,
    26  	"fmt.Fprintf.format":                     1,
    27  	"fmt.Printf.format":                      0,
    28  	"fmt.Sprintf.a[0]":                       1,
    29  	"fmt.Sprintf.format":                     0,
    30  	"json.Marshal.v":                         0,
    31  	"json.Unmarshal.v":                       1,
    32  	"len.v":                                  0,
    33  	"make.size[0]":                           1,
    34  	"make.size[1]":                           2,
    35  	"make.t":                                 0,
    36  	"net/url.Parse.rawurl":                   0,
    37  	"os.OpenFile.flag":                       1,
    38  	"os/exec.Command.name":                   0,
    39  	"os/signal.Notify.c":                     0,
    40  	"regexp.Compile.expr":                    0,
    41  	"runtime.SetFinalizer.finalizer":         1,
    42  	"runtime.SetFinalizer.obj":               0,
    43  	"sort.Sort.data":                         0,
    44  	"strconv.AppendFloat.bitSize":            4,
    45  	"strconv.AppendFloat.fmt":                2,
    46  	"strconv.AppendInt.base":                 2,
    47  	"strconv.AppendUint.base":                2,
    48  	"strconv.FormatComplex.bitSize":          3,
    49  	"strconv.FormatComplex.fmt":              1,
    50  	"strconv.FormatFloat.bitSize":            3,
    51  	"strconv.FormatFloat.fmt":                1,
    52  	"strconv.FormatInt.base":                 1,
    53  	"strconv.FormatUint.base":                1,
    54  	"strconv.ParseComplex.bitSize":           1,
    55  	"strconv.ParseFloat.bitSize":             1,
    56  	"strconv.ParseInt.base":                  1,
    57  	"strconv.ParseInt.bitSize":               2,
    58  	"strconv.ParseUint.base":                 1,
    59  	"strconv.ParseUint.bitSize":              2,
    60  	"time.Parse.layout":                      0,
    61  	"time.Sleep.d":                           0,
    62  	"xml.Marshal.v":                          0,
    63  	"xml.Unmarshal.v":                        1,
    64  }
    65  
    66  // Arg turns the name of an argument into an argument index.
    67  // Indices are zero-based and method receivers do not count as arguments.
    68  //
    69  // Arg refers to a manually compiled mapping (see the Args variable.)
    70  // Modify the knowledge package to add new arguments.
    71  func Arg(name string) int {
    72  	n, ok := Args[name]
    73  	if !ok {
    74  		panic("unknown argument " + name)
    75  	}
    76  	return n
    77  }