deps

package
v0.0.0-...-2c635fd Latest Latest
Warning

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

Go to latest
Published: May 1, 2019 License: MIT Imports: 10 Imported by: 0

Documentation

Index

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

type Graph map[Package]Set

func NewGraph

func NewGraph() Graph

func (Graph) AddPath

func (pg Graph) AddPath(path Path)

AddPath inserts the path into the graph.

func (Graph) AllPaths

func (pg Graph) AllPaths(start, end Package) Graph

AllPaths searches the graph for all paths from start to end.

func (Graph) AllPathsCond

func (pg Graph) AllPathsCond(start Package, endCond func(Package) bool) Graph

AllPathsCond searches the graph for all paths from start to a package matching the end condition.

func (Graph) DepthFirst

func (pg Graph) DepthFirst(start Package, walkFn WalkFn)

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

func (pg Graph) DepthLast(start Package, walkFn WalkFn)

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

func (Graph) Dot

func (pg Graph) Dot(root Package, labelFn func(Package) string) string

func (Graph) Has

func (pg Graph) Has(pkg Package) bool

func (Graph) List

func (pg Graph) List(root Package) []Package

func (Graph) Pkg

func (pg Graph) Pkg(pkg Package) Set

func (Graph) SomePath

func (pg Graph) SomePath(start, end Package) Path

SomePath searches the graph for any path from start to end.

func (Graph) SomePathCond

func (pg Graph) SomePathCond(start Package, endCond func(Package) bool) Path

SomePath searches the graph for any path from start to a package matching the end condition.

type Package

type Package string

Package is the full import path of a Go package.

const NullPackage Package = ""

func Resolve

func Resolve(importPath, basePath string, bctx build.Context) (Package, error)

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.

func StripVendor

func StripVendor(pkg Package) (Package, bool)

type Path

type Path []Package

func (Path) Last

func (p Path) Last() Package

func (Path) Pop

func (p Path) Pop() Path

type Set

type Set map[Package]present

func NewSet

func NewSet(pkgs ...Package) Set

func (Set) Delete

func (ps Set) Delete(pkg Package)

func (Set) Has

func (ps Set) Has(pkg Package) bool

func (Set) Insert

func (ps Set) Insert(pkg Package)

type WalkFn

type WalkFn func(pkg Package, edges Set, path Path) (followEdges, continueWalk bool)

WalkFn is the function used for graph searches. pkg is the package currently being evaluated edges is the set of edges from the current package path is the path from the search start to the current package

Jump to

Keyboard shortcuts

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