nilness

package
v0.4.6 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2023 License: MIT Imports: 8 Imported by: 12

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