...

Package genericfeatures

import "golang.org/x/tools/internal/typeparams/genericfeatures"
Overview
Index

Overview ▾

The genericfeatures package provides utilities for detecting usage of generic programming in Go packages.

type Features

Features is a set of flags reporting which features of generic Go code a package uses, or 0.

type Features int
const (
    // GenericTypeDecls indicates whether the package declares types with type
    // parameters.
    GenericTypeDecls Features = 1 << iota

    // GenericFuncDecls indicates whether the package declares functions with
    // type parameters.
    GenericFuncDecls

    // EmbeddedTypeSets indicates whether the package declares interfaces that
    // contain structural type restrictions, i.e. are not fully described by
    // their method sets.
    EmbeddedTypeSets

    // TypeInstantiation indicates whether the package instantiates any generic
    // types.
    TypeInstantiation

    // FuncInstantiation indicates whether the package instantiates any generic
    // functions.
    FuncInstantiation
)

func ForPackage

func ForPackage(inspect *inspector.Inspector, info *types.Info) Features

ForPackage computes which generic features are used directly by the package being analyzed.

func (Features) String

func (f Features) String() string