toolsgolang.org/x/tools/go/analysis/passes/usesgenerics Index | Files

package usesgenerics

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

Package usesgenerics defines an Analyzer that checks for usage of generic features added in Go 1.18.

Analyzer usesgenerics

usesgenerics: detect whether a package uses generics features

The usesgenerics analysis reports whether a package directly or transitively uses certain features associated with generic programming in Go.

Index

Constants

const (
	GenericTypeDecls  = genericfeatures.GenericTypeDecls
	GenericFuncDecls  = genericfeatures.GenericFuncDecls
	EmbeddedTypeSets  = genericfeatures.EmbeddedTypeSets
	TypeInstantiation = genericfeatures.TypeInstantiation
	FuncInstantiation = genericfeatures.FuncInstantiation
)

Variables

var Analyzer = &analysis.Analyzer{
	Name:       "usesgenerics",
	Doc:        analysisutil.MustExtractDoc(doc, "usesgenerics"),
	URL:        "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/usesgenerics",
	Requires:   []*analysis.Analyzer{inspect.Analyzer},
	Run:        run,
	ResultType: reflect.TypeOf((*Result)(nil)),
	FactTypes:  []analysis.Fact{new(featuresFact)},
}

Types

type Features

type Features = genericfeatures.Features

type Result

type Result struct {
	Direct, Transitive Features
}

Result is the usesgenerics analyzer result type. The Direct field records features used directly by the package being analyzed (i.e. contained in the package source code). The Transitive field records any features used by the package or any of its transitive imports.

Source Files

doc.go usesgenerics.go

Version
v0.30.0 (latest)
Published
Feb 10, 2025
Platform
linux/amd64
Imports
7 packages
Last checked
3 hours ago

Tools for package owners.