pkg

package
v0.0.0-...-7f9a030 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2016 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Resolve

func Resolve(importPath, basePath string, bctx build.Context) (string, 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.

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
}

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

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

func (Graph) Dot

func (pg Graph) Dot(root Package) 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

type Package

type Package string

Package is the full import path of a Go package.

const NullPackage Package = ""

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) (keepGoing bool)

Jump to

Keyboard shortcuts

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