package unusedresult

import "golang.org/x/tools/go/analysis/passes/unusedresult"

Package unusedresult defines an analyzer that checks for unused results of calls to certain pure functions.

Analyzer unusedresult

unusedresult: check for unused results of calls to some functions

Some functions like fmt.Errorf return a result and have no side effects, so it is always a mistake to discard the result. Other functions may return an error that must not be ignored, or a cleanup operation that must be called. This analyzer reports calls to functions like these when the result of the call is ignored.

The set of functions may be controlled using flags.

Package unusedresult defines an analyzer that checks for unused results of calls to certain functions.

Index

Variables

var Analyzer = &analysis.Analyzer{
	Name:     "unusedresult",
	Doc:      analysisutil.MustExtractDoc(doc, "unusedresult"),
	URL:      "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/unusedresult",
	Requires: []*analysis.Analyzer{inspect.Analyzer},
	Run:      run,
}

Source Files

doc.go unusedresult.go

Directories

PathSynopsis
go/analysis/passes/unusedresult/cmd
go/analysis/passes/unusedresult/cmd/unusedresultThe unusedresult command applies the golang.org/x/tools/go/analysis/passes/unusedresult analysis to the specified packages of Go source code.
Version
v0.30.0 (latest)
Published
Feb 10, 2025
Platform
linux/amd64
Imports
11 packages
Last checked
3 hours ago

Tools for package owners.