gotree

package module
v0.0.0-...-fb30aa0 Latest Latest
Warning

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

Go to latest
Published: May 16, 2019 License: MIT Imports: 9 Imported by: 0

README

gopkg

Print go dependency tree

gotree

Installation

go get github.com/MaruHyl/gotree/gotree

Command Help

Show deps like tree.

Usage:
  gotree [flags]

Flags:
  -h, --help             help for gotree
  -j, --json             Prints out an JSON representation of the tree
  -l, --max_level int    Set max level of tree
      --nointernal       Filter out internal packages
      --noreport         Turn off dep/direct/indirect count at end of tree listing
      --nostd            Filter out std packages
  -p, --pattern string   List only those deps that match the pattern given

Usage example

--max_level

Limit the depth of the tree, and can reduce the execution time of gotree

gotree -l 1

output

github.com/MaruHyl/gotree
├── encoding/json
├── errors
├── fmt
├── github.com/MaruHyl/gotree/internal/std
├── github.com/fatih/color
├── golang.org/x/tools/go/packages
├── regexp
├── sort
└── strings
9 deps, 9 direct, 0 indirect
--nostd

Ignore std packages, and can reduce the execution time of gotree

gotree -l 1 --nostd

output

github.com/MaruHyl/gotree
├── github.com/MaruHyl/gotree/internal/std
├── github.com/fatih/color
└── golang.org/x/tools/go/packages
3 deps, 3 direct, 0 indirect
--nointernal

Ignore internal packages

gotree -l 1 --nostd --nointernal

output

github.com/MaruHyl/gotree
├── github.com/fatih/color
└── golang.org/x/tools/go/packages
2 deps, 2 direct, 0 indirect
--pattern

List only those deps that match the pattern given.

gotree -p mattn/go-isatty

output

github.com/MaruHyl/gotree
└── github.com/fatih/color
    ├── github.com/mattn/go-colorable
    │   └── github.com/mattn/go-isatty
    └── github.com/mattn/go-isatty
4 deps, 1 direct, 3 indirect

Documentation

Index

Constants

View Source
const DefaultMaxLevel = 0 // no limit

Variables

This section is empty.

Functions

func JSONTree

func JSONTree(d Dep, options ...Option) (string, error)

Get dep graph(json)

func LoadPackages

func LoadPackages() (*packages.Package, error)

func Tree

func Tree(d Dep, options ...Option) (string, error)

Get dep graph(tree)

Types

type Dep

type Dep interface {
	Name() string
	Deps() []Dep
}

type Filter

type Filter interface {
	Filter(name string) bool
}

Filter will filter out the matched dep(return true)

func NewNopFilter

func NewNopFilter() Filter

func NewRegexpFilter

func NewRegexpFilter(pattern string) (Filter, error)

func NewReverseFilter

func NewReverseFilter(f Filter) Filter

type Option

type Option func(opts *options) error

func WithFilter

func WithFilter(filter Filter) Option

Filter will filter out the matched dep

func WithMaxLevel

func WithMaxLevel(maxLevel int) Option

Set max level of tree

func WithNoInternal

func WithNoInternal(noInternal bool) Option

Filter out internal pkg

func WithNoReport

func WithNoReport(noReport bool) Option

Turn off dep/direct/indirect count at end of tree listing

func WithNoStd

func WithNoStd(noStd bool) Option

Filter out std lib

type Type

type Type string
const (
	Root     Type = "root"
	Direct   Type = "direct"
	Indirect Type = "indirect"
	Report   Type = "report"
)

Directories

Path Synopsis
internal
std

Jump to

Keyboard shortcuts

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