nilness

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Analysis = &analysis.Analyzer{
	Name:       "nilness",
	Doc:        "Annotates return values that will never be nil (typed or untyped)",
	Run:        run,
	Requires:   []*analysis.Analyzer{buildir.Analyzer},
	FactTypes:  []analysis.Fact{(*neverReturnsNilFact)(nil)},
	ResultType: reflect.TypeOf((*Result)(nil)),
}

Functions

This section is empty.

Types

type Result

type Result struct {
	// contains filtered or unexported fields
}

func (*Result) MayReturnNil

func (r *Result) MayReturnNil(fn *types.Func, ret int) (yes bool, globalOnly bool)

MayReturnNil reports whether the ret's return value of fn might be a typed or untyped nil value. The value of ret is zero-based. When globalOnly is true, the only possible nil values are global variables.

The analysis has false positives: MayReturnNil can incorrectly report true, but never incorrectly reports false.

Jump to

Keyboard shortcuts

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