shared

package
v0.0.0-...-fdae9a8 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package shared provides common functionality for errutil analyzers.

Index

Constants

View Source
const ErrUtilPkg = "github.com/graxinc/errutil"

Variables

This section is empty.

Functions

func ErrorResultIndex

func ErrorResultIndex(sig *types.Signature) int

ErrorResultIndex returns the index of the error result in the signature, or -1 if none.

func FileForPos

func FileForPos(pass *analysis.Pass, pos token.Pos) token.Pos

FileForPos returns the file position for a given position.

func HasErrorResult

func HasErrorResult(sig *types.Signature) bool

HasErrorResult returns true if the signature has an error result.

func IsErrUtilCall

func IsErrUtilCall(call *ssa.Call) bool

IsErrUtilCall returns true if the call is to an errutil wrapping function.

func IsErrUtilWrapCall

func IsErrUtilWrapCall(call *ssa.Call) bool

IsErrUtilWrapCall returns true if the call is to errutil.With/Wrap/Witht/Wrapt (not New).

func IsErrorConstructor

func IsErrorConstructor(call *ssa.Call) bool

IsErrorConstructor returns true if the call is errors.New or fmt.Errorf.

func MarkSuppressed

func MarkSuppressed(directives []*Directive, filePos token.Pos, fnLine, targetLine int) bool

MarkSuppressed checks if a diagnostic at the given position should be suppressed. Returns true if suppressed, and marks the directive as used.

func ReportUnused

func ReportUnused(pass *analysis.Pass, directives []*Directive, message string)

ReportUnused reports all unused directives.

func WalkFunctions

func WalkFunctions(ssaInfo *ssa.Package, srcFuncs []*ssa.Function, fn func(*ssa.Function))

WalkFunctions walks all functions in the SSA including anonymous functions.

func WrapsErrorConstructor

func WrapsErrorConstructor(call *ssa.Call) bool

WrapsErrorConstructor returns true if the errutil.With/Wrap call wraps errors.New or fmt.Errorf.

Types

type Directive

type Directive struct {
	Pos  token.Pos
	File token.Pos
	Line int // -1 for filewide
	Used bool
}

Directive represents an analyzer directive comment.

func CollectDirectives

func CollectDirectives(pass *analysis.Pass, prefix string) []*Directive

CollectDirectives finds all directives matching the given prefix (e.g., "errwrap:ignore").

Jump to

Keyboard shortcuts

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