package unused
import "honnef.co/go/tools/unused"
Package unused contains code for finding unused code.
Index ¶
- Variables
- type Node
- type NodeID
- type Object
- type ObjectPath
- type Options
- type Result
- type SerializedGraph
Variables ¶
var Analyzer = &lint.Analyzer{ Doc: &lint.RawDocumentation{ Title: "Unused code", }, Analyzer: &analysis.Analyzer{ Name: "U1000", Doc: "Unused code", Run: run, Requires: []*analysis.Analyzer{generated.Analyzer, directives.Analyzer}, ResultType: reflect.TypeOf(Result{}), }, }
var DefaultOptions = Options{ FieldWritesAreUses: true, PostStatementsAreReads: false, ExportedIsUsed: true, ExportedFieldsAreUsed: true, ParametersAreUsed: true, LocalVariablesAreUsed: true, GeneratedIsUsed: true, }
Types ¶
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
func Graph ¶
func Graph(fset *token.FileSet, files []*ast.File, pkg *types.Package, info *types.Info, directives []lint.Directive, generated map[string]generated.Generator, opts Options, ) []Node
type NodeID ¶
type NodeID uint64
OPT(dh): 32 bits would be plenty, but the Node struct would end up with padding, anyway.
type Object ¶
type Object struct { Name string ShortName string // OPT(dh): use an enum for the kind Kind string Path ObjectPath Position token.Position DisplayPosition token.Position }
type ObjectPath ¶
type ObjectPath struct { PkgPath string ObjPath objectpath.Path }
type Options ¶
type Options struct { FieldWritesAreUses bool PostStatementsAreReads bool ExportedIsUsed bool ExportedFieldsAreUsed bool ParametersAreUsed bool LocalVariablesAreUsed bool GeneratedIsUsed bool }
type Result ¶
TODO(dh): should we return a map instead of two slices?
type SerializedGraph ¶
type SerializedGraph struct {
// contains filtered or unexported fields
}
func (*SerializedGraph) Dot ¶
func (g *SerializedGraph) Dot() string
Dot formats a graph in Graphviz dot format.
func (*SerializedGraph) Merge ¶
func (g *SerializedGraph) Merge(nodes []Node)
func (*SerializedGraph) Results ¶
func (g *SerializedGraph) Results() Result
Source Files ¶
implements.go runtime.go serialize.go unused.go
- Version
- v0.7.0-0.dev
- Published
- Mar 5, 2025
- Platform
- js/wasm
- Imports
- 16 packages
- Last checked
- 2 minutes ago –
Tools for package owners.