pkgset

package
v0.10.2 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsStd

func IsStd(p *packages.Package) bool

IsStd returns whether *packages.Package is a std package

func IsStdName

func IsStdName(id string) bool

IsStdName returns whether id corresponds to a standard package

func IsTestPkg added in v0.5.0

func IsTestPkg(pkg *packages.Package) bool

func KeyValue

func KeyValue(s string) (string, string)

KeyValue parses s into a key and value.

func LoadStd added in v0.5.3

func LoadStd()

LoadStd preloads the std package list.

func Parse

func Parse(_ context.Context, expr []string) (ast.Expr, error)

Parse converts the expression represented by the expr strings into an AST representation.

Types

type Context

type Context struct {
	Context context.Context
	Tags    Strings
	Env     Strings

	Variables map[string]Set
}

func (Context) Clone

func (ctx Context) Clone() *Context

func (Context) Config

func (ctx Context) Config() *packages.Config

func (Context) Load

func (ctx Context) Load(patterns ...string) ([]*packages.Package, error)

func (Context) LoadWithTests added in v0.4.2

func (ctx Context) LoadWithTests(patterns ...string) ([]*packages.Package, error)

func (Context) LoadWithoutTests added in v0.4.2

func (ctx Context) LoadWithoutTests(patterns ...string) ([]*packages.Package, error)

func (*Context) Set

func (ctx *Context) Set(key, value string)

type Set

type Set map[string]*packages.Package

Set is a p.ID -> *packages.Package

func Calc

func Calc(parentContext context.Context, expr []string) (Set, error)

Calc parses expr and computes the set of packages it describes.

func Deadcode added in v0.9.0

func Deadcode(ctx *Context, pkgs Set) (Set, error)

Deadcode returns packages from the set that directly or indirectly call a function annotated with <ReflectMethod> in the linker dependency graph. This is typically caused by reflect.Value.MethodByName or similar calls, which force the linker to keep all interface methods alive.

func DirectDependencies

func DirectDependencies(a Set) Set

DirectDependencies returns packages that are direct dependencies of a, `a` not included.

func Incoming

func Incoming(a, b Set) Set

Incoming returns packages from a that directly import packages in b.

func Intersect

func Intersect(a, b Set) Set

Intersect returns packages that exist in both

func Main

func Main(a Set) Set

Main returns main pacakges.

func ModuleDependencies added in v0.6.0

func ModuleDependencies(a Set) Set

ModuleDependencies returns packages that are direct or indirect dependencies of a, which are part of modules of package a.

func New

func New(roots ...*packages.Package) Set

New makes a set from roots recursively

func NewAll

func NewAll(src Set) Set

NewAll includes all the dependencies from the graph.

func NewRoot

func NewRoot(roots ...*packages.Package) Set

NewRoot makes a set from roots recursively

func Reach

func Reach(a, b Set) Set

Reach returns packages in a that terminate in b

func Sources

func Sources(a Set) Set

Sources returns packages that don't have incoming edges, only considering edges between packages in the set.

func Std

func Std() Set

Std returns the standard package set

func Subtract

func Subtract(a, b Set) Set

Subtract returns packages that exist in a, but not in b

func SymmetricDifference

func SymmetricDifference(a, b Set) Set

SymmetricDifference returns packages that are different

func Test added in v0.4.2

func Test(a Set) Set

Test returns test packages from set.

func Transitive

func Transitive(a Set) Set

Transitive returns transitive reduction.

func Union

func Union(a, b Set) Set

Union includes packages from both sets

func UnionAll added in v0.6.1

func UnionAll(xs ...Set) Set

UnionAll includes packages from both sets

func (Set) Clone

func (set Set) Clone() Set

Clone makes a copy of the set

func (Set) IDs added in v0.4.2

func (set Set) IDs() []string

IDs returns package ID-s in sorted order.

func (Set) IncludeRecursive

func (set Set) IncludeRecursive(p *packages.Package)

IncludeRecursive adds p recursively

func (Set) List

func (set Set) List() []*packages.Package

List returns packages in unsorted order.

func (Set) Sorted

func (set Set) Sorted() []*packages.Package

Sorted returns packages in sorted order

func (Set) Walk

func (set Set) Walk(fn func(*packages.Package))

func (Set) WalkAllDependencies added in v0.7.1

func (set Set) WalkAllDependencies(fn func(*packages.Package))

WalkAllDependencies walks all dependencies of the set, including ones not part of the set.

type Strings

type Strings []string

func (Strings) Clone

func (strs Strings) Clone() Strings

func (Strings) IndexOf

func (strs Strings) IndexOf(key string) int

func (*Strings) Set

func (strs *Strings) Set(key, value string)

func (Strings) ValueOf

func (strs Strings) ValueOf(key string) string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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