Documentation
¶
Overview ¶
Package fillreturns defines an Analyzer that will attempt to automatically fill in a return statement that has missing values with zero value elements.
Analyzer fillreturns ¶
fillreturns: suggest fixes for errors due to an incorrect number of return values
This checker provides suggested fixes for type errors of the type "wrong number of return values (want %d, got %d)". For example:
func m() (int, string, *bool, error) {
return
}
will turn into
func m() (int, string, *bool, error) {
return 0, "", nil, nil
}
This functionality is similar to https://github.com/sqs/goreturns.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Analyzer = &analysis.Analyzer{ Name: "fillreturns", Doc: analyzerutil.MustExtractDoc(doc, "fillreturns"), Requires: []*analysis.Analyzer{inspect.Analyzer}, Run: run, RunDespiteErrors: true, URL: "https://pkg.go.dev/golang.org/x/tools/gopls/internal/analysis/fillreturns", }
Functions ¶
func MatchingIdents ¶
func MatchingIdents(typs []types.Type, node ast.Node, pos token.Pos, info *types.Info, pkg *types.Package) map[types.Type][]string
MatchingIdents finds the names of all identifiers in 'node' that match any of the given types. 'pos' represents the position at which the identifiers may be inserted. 'pos' must be within the scope of each of identifier we select. Otherwise, we will insert a variable at 'pos' that is unrecognized.
This function is shared with the 'fillstruct' analyzer.
Types ¶
This section is empty.