Documentation
¶
Index ¶
- type Builder
- type Condition
- type Dependencies
- type DependencyInfo
- type Graph
- func (pg Graph) AddPath(path Path)
- func (pg Graph) AllPaths(start, end Package) Graph
- func (pg Graph) AllPathsCond(start Package, endCond func(Package) bool) Graph
- func (pg Graph) DepthFirst(start Package, walkFn WalkFn)
- func (pg Graph) DepthLast(start Package, walkFn WalkFn)
- func (pg Graph) Dot(root Package, labelFn func(Package) string) string
- func (pg Graph) Has(pkg Package) bool
- func (pg Graph) List(root Package) []Package
- func (pg Graph) Pkg(pkg Package) Set
- func (pg Graph) SomePath(start, end Package) Path
- func (pg Graph) SomePathCond(start Package, endCond func(Package) bool) Path
- type Package
- type Path
- type Set
- type WalkFn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Builder ¶
type Builder struct { // The base directory for relative imports. BaseDir string // The roots of the dependency graph (source packages). Roots []Package // Stop building the graph if ANY conditions are met. TerminationConditions []Condition // Ignore any packages that match any of these patterns. // Tested on the resolved package path. Ignored []*regexp.Regexp // Include only packages that match any of these patterns. // Tested on the resolved package path. Included []*regexp.Regexp // Whether tests should be included in the dependencies. IncludeTests bool // Whether to include standard library packages IncludeStdlib bool // The build context for processing imports. BuildContext build.Context // contains filtered or unexported fields }
func (*Builder) Build ¶
func (b *Builder) Build() (Dependencies, error)
type Condition ¶
type Condition func(Dependencies) bool
type Dependencies ¶
type Dependencies struct { // Map of package -> dependencies. Forward Graph // Packages which were ignored. Ignored Set Info map[Package]*DependencyInfo }
type DependencyInfo ¶
type DependencyInfo struct {
LOC int
}
type Graph ¶
func (Graph) AllPathsCond ¶
AllPathsCond searches the graph for all paths from start to a package matching the end condition.
func (Graph) DepthFirst ¶
Walk the graph depth first, starting at start and calling walkFn on each node visited. Each node will be visited at most once.
func (Graph) DepthLast ¶
Walk the graph "depth last", starting at start and calling walkFn on each node visited. Each node will be visited at most once. Nodes will be visited "depth last", where depth is defined as the maximum distance from the start. TODO: (if needed) add path to WalkFn TODO: correctly handle !followEdges from WalkFn
type Package ¶
type Package string
Package is the full import path of a Go package.
const NullPackage Package = ""
func Resolve ¶
Resolve resolves import paths to a canonical, absolute form. Relative paths are resolved relative to basePath. It does not verify that the import is valid.