knowledge

package
v0.0.0-...-b9adcda Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 14, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package knowledge contains manually collected information about Go APIs.

Index

Constants

View Source
const (
	// DeprecatedNeverUse indicates that an API should never be used, regardless of Go version.
	DeprecatedNeverUse = "never"
	// DeprecatedUseNoLonger indicates that an API has no use anymore.
	DeprecatedUseNoLonger = "no longer"
)

Variables

View Source
var Args = map[string]int{
	"(*sync.Pool).Put.x":                     0,
	"(*text/template.Template).Parse.text":   0,
	"(io.Seeker).Seek.offset":                0,
	"(time.Time).Sub.u":                      0,
	"append.elems":                           1,
	"append.slice":                           0,
	"bytes.Equal.a":                          0,
	"bytes.Equal.b":                          1,
	"encoding/ascii85.Encode.dst":            0,
	"encoding/ascii85.Encode.src":            1,
	"(*encoding/base32.Encoding).Encode.dst": 0,
	"(*encoding/base32.Encoding).Encode.src": 1,
	"(*encoding/base64.Encoding).Encode.dst": 0,
	"(*encoding/base64.Encoding).Encode.src": 1,
	"encoding/binary.Write.data":             2,
	"encoding/hex.Encode.dst":                0,
	"encoding/hex.Encode.src":                1,
	"(*encoding/json.Decoder).Decode.v":      0,
	"(*encoding/json.Encoder).Encode.v":      0,
	"(*encoding/xml.Decoder).Decode.v":       0,
	"(*encoding/xml.Encoder).Encode.v":       0,
	"errors.New.text":                        0,
	"fmt.Fprintf.format":                     1,
	"fmt.Printf.format":                      0,
	"fmt.Sprintf.a[0]":                       1,
	"fmt.Sprintf.format":                     0,
	"json.Marshal.v":                         0,
	"json.Unmarshal.v":                       1,
	"len.v":                                  0,
	"make.size[0]":                           1,
	"make.size[1]":                           2,
	"make.t":                                 0,
	"net/url.Parse.rawurl":                   0,
	"os.OpenFile.flag":                       1,
	"os/exec.Command.name":                   0,
	"os/signal.Notify.c":                     0,
	"regexp.Compile.expr":                    0,
	"runtime.SetFinalizer.finalizer":         1,
	"runtime.SetFinalizer.obj":               0,
	"sort.Sort.data":                         0,
	"strconv.AppendFloat.bitSize":            4,
	"strconv.AppendFloat.fmt":                2,
	"strconv.AppendInt.base":                 2,
	"strconv.AppendUint.base":                2,
	"strconv.FormatComplex.bitSize":          3,
	"strconv.FormatComplex.fmt":              1,
	"strconv.FormatFloat.bitSize":            3,
	"strconv.FormatFloat.fmt":                1,
	"strconv.FormatInt.base":                 1,
	"strconv.FormatUint.base":                1,
	"strconv.ParseComplex.bitSize":           1,
	"strconv.ParseFloat.bitSize":             1,
	"strconv.ParseInt.base":                  1,
	"strconv.ParseInt.bitSize":               2,
	"strconv.ParseUint.base":                 1,
	"strconv.ParseUint.bitSize":              2,
	"time.Parse.layout":                      0,
	"time.Sleep.d":                           0,
	"xml.Marshal.v":                          0,
	"xml.Unmarshal.v":                        1,
}
View Source
var Interfaces = map[string]*types.Interface{
	"fmt.Stringer": types.NewInterfaceType(
		[]*types.Func{
			types.NewFunc(token.NoPos, nil, "String", Signatures["(fmt.Stringer).String"]),
		},
		nil,
	).Complete(),

	"error": types.Universe.Lookup("error").Type().Underlying().(*types.Interface),

	"io.Writer": types.NewInterfaceType(
		[]*types.Func{
			types.NewFunc(token.NoPos, nil, "Write", Signatures["(io.Writer).Write"]),
		},
		nil,
	).Complete(),

	"io.StringWriter": types.NewInterfaceType(
		[]*types.Func{
			types.NewFunc(token.NoPos, nil, "WriteString", Signatures["(io.StringWriter).WriteString"]),
		},
		nil,
	).Complete(),

	"encoding.TextMarshaler": types.NewInterfaceType(
		[]*types.Func{
			types.NewFunc(token.NoPos, nil, "MarshalText", Signatures["(encoding.TextMarshaler).MarshalText"]),
		},
		nil,
	).Complete(),

	"encoding/json.Marshaler": types.NewInterfaceType(
		[]*types.Func{
			types.NewFunc(token.NoPos, nil, "MarshalJSON", Signatures["(encoding/json.Marshaler).MarshalJSON"]),
		},
		nil,
	).Complete(),
}
View Source
var KnownGOARCH = map[string]struct{}{
	"386":      {},
	"amd64":    {},
	"arm":      {},
	"arm64":    {},
	"loong64":  {},
	"mips":     {},
	"mipsle":   {},
	"mips64":   {},
	"mips64le": {},
	"ppc64":    {},
	"ppc64le":  {},
	"riscv64":  {},
	"s390x":    {},
	"sparc64":  {},
	"wasm":     {},
}
View Source
var KnownGOOS = map[string]struct{}{
	"aix":       {},
	"android":   {},
	"darwin":    {},
	"dragonfly": {},
	"freebsd":   {},
	"hurd":      {},
	"illumos":   {},
	"ios":       {},
	"js":        {},
	"linux":     {},
	"netbsd":    {},
	"openbsd":   {},
	"plan9":     {},
	"solaris":   {},
	"wasip1":    {},
	"windows":   {},
}
View Source
var Signatures = map[string]*types.Signature{
	"(io.Seeker).Seek": types.NewSignatureType(nil, nil, nil,
		types.NewTuple(
			types.NewParam(token.NoPos, nil, "", types.Typ[types.Int64]),
			types.NewParam(token.NoPos, nil, "", types.Typ[types.Int]),
		),
		types.NewTuple(
			types.NewParam(token.NoPos, nil, "", types.Typ[types.Int64]),
			types.NewParam(token.NoPos, nil, "", types.Universe.Lookup("error").Type()),
		),
		false,
	),

	"(io.Writer).Write": types.NewSignatureType(nil, nil, nil,
		types.NewTuple(
			types.NewParam(token.NoPos, nil, "", types.NewSlice(types.Typ[types.Byte])),
		),
		types.NewTuple(
			types.NewParam(token.NoPos, nil, "", types.Typ[types.Int]),
			types.NewParam(token.NoPos, nil, "", types.Universe.Lookup("error").Type()),
		),
		false,
	),

	"(io.StringWriter).WriteString": types.NewSignatureType(nil, nil, nil,
		types.NewTuple(
			types.NewParam(token.NoPos, nil, "", types.Typ[types.String]),
		),
		types.NewTuple(
			types.NewParam(token.NoPos, nil, "", types.Typ[types.Int]),
			types.NewParam(token.NoPos, nil, "", types.Universe.Lookup("error").Type()),
		),
		false,
	),

	"(encoding.TextMarshaler).MarshalText": types.NewSignatureType(nil, nil, nil,
		types.NewTuple(),
		types.NewTuple(
			types.NewParam(token.NoPos, nil, "", types.NewSlice(types.Typ[types.Byte])),
			types.NewParam(token.NoPos, nil, "", types.Universe.Lookup("error").Type()),
		),
		false,
	),

	"(encoding/json.Marshaler).MarshalJSON": types.NewSignatureType(nil, nil, nil,
		types.NewTuple(),
		types.NewTuple(
			types.NewParam(token.NoPos, nil, "", types.NewSlice(types.Typ[types.Byte])),
			types.NewParam(token.NoPos, nil, "", types.Universe.Lookup("error").Type()),
		),
		false,
	),

	"(fmt.Stringer).String": types.NewSignatureType(nil, nil, nil,
		types.NewTuple(),
		types.NewTuple(
			types.NewParam(token.NoPos, nil, "", types.Typ[types.String]),
		),
		false,
	),
}
View Source
var StdlibDeprecations = map[string]Deprecation{}/* 161 elements not displayed */

StdlibDeprecations contains a mapping of Go API (such as variables, methods, or fields, among others) to information about when it has been deprecated.

Functions

func Arg

func Arg(name string) int

Arg turns the name of an argument into an argument index. Indices are zero-based and method receivers do not count as arguments.

Arg refers to a manually compiled mapping (see the Args variable.) Modify the knowledge package to add new arguments.

Types

type Deprecation

type Deprecation struct {
	// The minor Go version since which this API has been deprecated.
	DeprecatedSince string
	// The minor Go version since which an alternative API has been available.
	// May also be one of DeprecatedNeverUse or DeprecatedUseNoLonger.
	AlternativeAvailableSince string
}

Deprecation describes when a Go API has been deprecated.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL