slice

package
v0.0.0-...-d0c129d Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package slice computes minimal dependency slices for Go declarations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DeclInfo

type DeclInfo struct {
	Obj     types.Object
	Node    ast.Node
	File    *ast.File // containing file for comment preservation
	PkgPath string
}

DeclInfo holds information about a declaration in the slice.

type Result

type Result struct {
	Fset            *token.FileSet
	Decls           []DeclInfo
	Imports         map[string]string // import path -> local name (non-internal only)
	InlinedPkgNames map[string]bool   // package names that were inlined (e.g., "abi", "bytealg")
	RootPkgPkg      string
}

Result holds the computed slice.

func (*Result) Output

func (r *Result) Output(pkgName string) ([]byte, error)

Output formats the slice result as compilable Go source. Declarations from internal packages are inlined with package origin comments. Qualified identifiers referencing inlined packages are rewritten to unqualified names.

type Slicer

type Slicer struct {
	// contains filtered or unexported fields
}

Slicer computes dependency slices for Go declarations.

func New

func New(patterns ...string) (*Slicer, error)

New creates a Slicer for the given package patterns.

func (*Slicer) Slice

func (s *Slicer) Slice(roots ...string) (*Result, error)

Slice computes the minimal dependency slice for the given root symbols. Each root is specified as "Name" for the root package or "pkg.Name" for imported packages.

Jump to

Keyboard shortcuts

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