tree

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2020 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Blue   = "#76E1FE"
	Green  = "green"
	Orange = "#fcd92d"
	Red    = "red"

	BrokenColor       = Red
	RootColor         = Green
	SingleParentColor = Orange
	UserKeepColor     = Blue
)

just some constants for use with the tree output

Variables

This section is empty.

Functions

This section is empty.

Types

type Leaf

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

Leaf contains helpful information about each package, like the package itself, a friendly display name, and whether or not the tree wants to keep it.

func NewLeaf

func NewLeaf(displayName string) *Leaf

NewLeaf returns a new leaf.

func (*Leaf) ImportCount

func (l *Leaf) ImportCount() int

ImportCount returns the receiver's import-count

func (*Leaf) IsBroken

func (l *Leaf) IsBroken() bool

IsBroken returns if the receiver is broken or not

func (*Leaf) IsRoot

func (l *Leaf) IsRoot() bool

IsRoot returns whether the receiver is a "root" leaf or not

func (*Leaf) SetDisplayName

func (l *Leaf) SetDisplayName(name string)

SetDisplayName modifies the receiver's display name

func (*Leaf) SetRoot

func (l *Leaf) SetRoot(root bool)

SetRoot sets whether the receiver is a root or not.

func (*Leaf) String

func (l *Leaf) String() string

type Tree

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

Tree isn't actually a tree structure, but maintains a map of package names to Leaves.

func NewTree

func NewTree(parentDirectory string) *Tree

NewTree returns a new, empty Tree

func (*Tree) Add

func (t *Tree) Add(name string) (bool, error)

Add will attempt to add a package to the tree as a "root".

func (*Tree) AddRecursive

func (t *Tree) AddRecursive(name string) (bool, error)

AddRecursive will attempt to add a package to the tree as a "root". Then, it will recursively call itself on all of that package's imports.

func (*Tree) Branch

func (t *Tree) Branch(b string) error

Branch marks all packages between the given package and the root for keeping.

func (*Tree) Broaden

func (t *Tree) Broaden() []map[string]string

Broaden returns a list of maps. Each map has one key, and that key and value each represent a package name. Each map represents "this package imports that package".

func (*Tree) Graphviz

func (t *Tree) Graphviz() (string, error)

Graphviz returns the tree's representation in the graphviz source language, as for use with the `dot` command-line tool. See https://graphviz.org/documentation/ for more information.

func (*Tree) Grow

func (t *Tree) Grow(count int)

Grow expands the "tree" of kept packages by the given count. This works in both directions (ancestors and descendants).

func (*Tree) Keep

func (t *Tree) Keep(name string) error

Keep marks a single package in the receiver for keeping. Should only be used as a result of user action (e.g. not for automatic "grow" operations)

func (*Tree) PackageNames

func (t *Tree) PackageNames() []string

PackageNames returns a sorted list of all of the tree's packages

func (*Tree) Prune

func (t *Tree) Prune()

Prune removes all packages and package imports from the tree that are not marked for keeping.

func (*Tree) SetIncludeExts

func (t *Tree) SetIncludeExts(includeExts bool)

SetIncludeExts modifies the receiver to include or exclude packages outside the receiver's parent directory.

func (*Tree) SetIncludeTests

func (t *Tree) SetIncludeTests(includeTests bool)

SetIncludeTests modifies the receiver to include or exclude imports from Go test files.

func (*Tree) Stats

func (t *Tree) Stats() string

Stats returns a string of the receiver's statistics

func (*Tree) String

func (t *Tree) String() string

Jump to

Keyboard shortcuts

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