stdmethods

Imports

Imports #

_ "embed"
"go/ast"
"go/types"
"strings"
"golang.org/x/tools/go/analysis"
"golang.org/x/tools/go/analysis/passes/inspect"
"golang.org/x/tools/go/analysis/passes/internal/analysisutil"
"golang.org/x/tools/go/ast/inspector"

Constants & Variables

Analyzer var #

var Analyzer = *ast.UnaryExpr

canonicalMethods var #

canonicalMethods lists the input and output types for Go methods that are checked using dynamic interface checks. Because the checks are dynamic, such methods would not cause a compile error if they have the wrong signature: instead the dynamic check would fail, sometimes mysteriously. If a method is found with a name listed here but not the input/output types listed here, vet complains. A few of the canonical methods have very common names. For example, a type might implement a Scan method that has nothing to do with fmt.Scanner, but we still want to check the methods that are intended to implement fmt.Scanner. To do that, the arguments that have a = prefix are treated as signals that the canonical meaning is intended: if a Scan method doesn't have a fmt.ScanState as its first argument, we let it go. But if it does have a fmt.ScanState, then the rest has to match.

var canonicalMethods = map[string]struct{...}{...}

doc var #

go:embed doc.go

var doc string

errorType var #

var errorType = *ast.TypeAssertExpr

Functions

argjoin function #

func argjoin(x []string) string

canonicalMethod function #

func canonicalMethod(pass *analysis.Pass, id *ast.Ident)

implementsError function #

func implementsError(actual types.Type) bool

matchParamType function #

Does this one type match?

func matchParamType(expect string, actual types.Type) bool

matchParams function #

Does each type in expect with the given prefix match the corresponding type in actual?

func matchParams(pass *analysis.Pass, expect []string, actual *types.Tuple, prefix string) bool

run function #

func run(pass *analysis.Pass) (interface{}, error)

typeString function #

func typeString(typ types.Type) string

Generated with Arrow