Skip to content

vc60er/deptree

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

deptree

show golang dependence like tree

How to get it

➜ go install github.com/vc60er/deptree@latest
➜ export PATH=$PATH:$GOPATH/bin

Usage

params

Usage of deptree:
  -a  show all dependencies, also without upgrade and point out duplicated children
  -c  upgrade candidates will be marked yellow
  -d int
      max depth of dependencies (default 3)
  -f  force show of each occurrence of a child branch in tree (can cause hang)
  -graph string
      path to file created e.g. by 'go mod graph > grapphfile.txt'
  -json
      print JSON instead of tree
  -t  visualize trimmed tree by '└─...'
  -upgrade string
      path to file created e.g. by 'go list -u -m -json all > upgradefile.txt'
  -v int
      be more verbose

example

➜  redis git:(master) go mod graph | deptree -d 2 -t -a
call 'go list -u -m -json all', be patient...
dependency tree with depth 2 for package: gobot.io/x/gobot, least 99 trimmed item(s)
* tree of duplicate children not drawn (-f not set)
* 12 duplicate child trees replaced by links

gobot.io/x/gobot (go1.17)
 ├── github.com/bmizerany/[email protected]
 ├── github.com/cpuguy83/go-md2man/[email protected] (go1.11)
 │    └── github.com/russross/blackfriday/[email protected]
 ├── github.com/creack/[email protected] (go1.13)
 ├── github.com/davecgh/[email protected]
 ├── github.com/donovanhide/[email protected]
 ├── github.com/eclipse/[email protected] (go1.14) => [v1.4.2]
 │    ├── github.com/gorilla/[email protected] => [v1.5.0] (go1.12)
 │    ├── golang.org/x/[email protected] => [v0.10.0]
 │    │    └── 3 more ...
 │    └── golang.org/x/[email protected] => [v0.2.0]
 ├── github.com/fatih/[email protected]
 ├── <2> github.com/go-ole/[email protected] (go1.12)
 │    └── golang.org/x/[email protected] => [v0.8.0]
 ├── github.com/godbus/dbus/[email protected] (go1.12)
 ├── github.com/gofrs/[email protected]+incompatible => [v4.4.0+incompatible]
 ├── <7> github.com/golang/[email protected] (go1.9) => [v1.5.3]
 │    ├── <8> github.com/google/[email protected] (go1.8) => [v0.5.9]
 │    │    └── 1 more ...
 │    └── google.golang.org/[email protected] => [v1.30.0]
 │         └── 1 more ...
 ├── github.com/gorilla/[email protected] (go1.12)
 ├── github.com/hashicorp/[email protected]
 ├── github.com/hashicorp/[email protected] (go1.13)
 │    └── github.com/hashicorp/[email protected] => [v1.1.0]
 ├── github.com/hybridgroup/[email protected]
 ├── github.com/hybridgroup/[email protected]
 ├── <10> github.com/muka/[email protected] (go1.14) => [v0.0.0-20221213043340-85dc80edc4e1]
 │    ├── github.com/fatih/[email protected]
 │    ├── github.com/godbus/dbus/[email protected] => [v5.1.0] (go1.12)
 │    ├── github.com/niemeyer/[email protected] (go1.12)
 │    │    └── 1 more ...
 │    ├── github.com/pkg/[email protected]
 │    ├── github.com/sirupsen/[email protected] => [v1.9.0] (go1.13)
 │    │    └── 5 more ...
 │    ├── github.com/stretchr/[email protected] => [v1.8.2]
 │    │    └── 4 more ...
 │    ├── github.com/suapapa/[email protected] (go1.14)
 │    │    └── 2 more ...
 │    ├── golang.org/x/[email protected] => [v0.8.0]
 │    ├── golang.org/x/[email protected] => [v0.9.1]
 │    │    └── 5 more ...
 │    └── gopkg.in/[email protected] => [v1.0.0-20201130134442-10cb98267c6c]
 ├── github.com/nats-io/nats-server/[email protected] => [v2.9.16]
 │    ├── github.com/golang/[email protected] => [v1.5.3]
 │    ├── github.com/nats-io/[email protected] => [v1.2.2]
 │    │    └── 1 more ...
 │    ├── github.com/nats-io/[email protected] => [v1.25.0]
 │    │    └── 2 more ...
 │    ├── github.com/nats-io/[email protected] => [v0.4.4]
 │    │    └── 1 more ...
 │    ├── github.com/nats-io/[email protected]
 │    ├── golang.org/x/[email protected] => [v0.9.0]
 │    │    └── 2 more ...
 │    └── golang.org/x/[email protected] => [v0.8.0]
 ├── github.com/nats-io/[email protected] (go1.16) => [v1.25.0]
 │    ├── github.com/nats-io/[email protected] (go1.16) => [v0.4.4], see <1> for 1 children (branch 'gobot.io/x/gobot' level 1)
 │    └── github.com/nats-io/[email protected]
 ├── <1> github.com/nats-io/[email protected] (go1.16) => [v0.4.4]
 │    └── golang.org/x/[email protected] => [v0.9.0]
 │         └── 3 more ...
 ├── github.com/nats-io/[email protected]
 ├── github.com/pkg/[email protected]
 ├── github.com/pmezard/[email protected]
 ├── github.com/russross/blackfriday/[email protected]
 ├── github.com/saltosystems/[email protected] (go1.18) => [v0.0.0-20230510070731-e096b9afa761]
 │    ├── github.com/glerchundi/[email protected]
 │    ├── github.com/go-kit/[email protected] (go1.17)
 │    │    └── 1 more ...
 │    ├── github.com/go-ole/[email protected] (go1.12), see <2> for 1 children (branch 'gobot.io/x/gobot' level 1)
 │    ├── github.com/peterbourgon/ff/[email protected] (go1.16) => [v3.3.1]
 │    │    └── 2 more ...
 │    ├── github.com/stretchr/[email protected] => [v1.8.2]
 │    │    └── 4 more ...
 │    ├── github.com/tdakkota/[email protected] (go1.16)
 │    │    └── 2 more ...
 │    ├── golang.org/x/[email protected] (go1.17) => [v0.9.1]
 │    │    └── 6 more ...
 │    ├── github.com/davecgh/[email protected]
 │    ├── github.com/go-logfmt/[email protected] (go1.17) => [v0.6.0]
 │    ├── github.com/pmezard/[email protected]
 │    ├── golang.org/x/[email protected] (go1.17) => [v0.10.0]
 │    │    └── 2 more ...
 │    ├── golang.org/x/[email protected] => [v0.8.0]
 │    └── gopkg.in/[email protected], see <3> for 1 children (branch 'gobot.io/x/gobot' level 1)
 ├── github.com/sigurn/[email protected] (go1.17)
 ├── <11> github.com/sirupsen/[email protected] (go1.13)
 │    ├── github.com/davecgh/[email protected]
 │    ├── <5> github.com/stretchr/[email protected] => [v1.8.2]
 │    │    └── 4 more ...
 │    └── golang.org/x/[email protected] => [v0.8.0]
 ├── github.com/stretchr/[email protected] (go1.13) => [v1.8.2]
 │    ├── github.com/davecgh/[email protected]
 │    ├── github.com/pmezard/[email protected]
 │    ├── github.com/stretchr/[email protected] (go1.12) => [v0.5.0]
 │    │    └── 2 more ...
 │    └── gopkg.in/[email protected], see <3> for 1 children (branch 'gobot.io/x/gobot' level 1)
 ├── <12> github.com/tinygo-org/[email protected] (go1.14)
 │    └── github.com/sirupsen/[email protected] => [v1.9.0] (go1.13)
 │         └── 5 more ...
 ├── github.com/urfave/[email protected] (go1.11) => [v1.22.13]
 │    ├── github.com/BurntSushi/[email protected] => [v1.2.1]
 │    ├── github.com/cpuguy83/go-md2man/[email protected] => [v2.0.2] (go1.11)
 │    │    └── 3 more ...
 │    └── <4> gopkg.in/[email protected] => [v2.4.0]
 │         └── 1 more ...
 ├── github.com/veandco/[email protected] (go1.15) => [v0.4.35]
 ├── github.com/warthog618/[email protected] (go1.17) => [v0.8.1]
 │    ├── github.com/pilebones/[email protected] => [v0.9.0]
 │    ├── github.com/spf13/[email protected] (go1.12) => [v1.7.0]
 │    ├── github.com/spf13/[email protected] (go1.12)
 │    ├── github.com/stretchr/[email protected] => [v1.8.2]
 │    ├── github.com/warthog618/[email protected] (go1.11) => [v0.5.1]
 │    ├── golang.org/x/[email protected] => [v0.8.0]
 │    ├── gopkg.in/[email protected] => [v1.0.0-20201130134442-10cb98267c6c]
 │    ├── github.com/davecgh/[email protected]
 │    ├── github.com/fsnotify/[email protected] => [v1.6.0]
 │    ├── github.com/inconshreveable/[email protected] => [v1.1.0]
 │    ├── github.com/pkg/[email protected] => [v0.9.1]
 │    ├── github.com/pmezard/[email protected]
 │    └── gopkg.in/[email protected] => [v2.4.0], see <4> for 1 children (branch 'github.com/urfave/[email protected]' level 2)
 ├── go.bug.st/[email protected] (go1.17) => [v1.5.0]
 │    ├── github.com/creack/[email protected] (go1.13)
 │    ├── github.com/stretchr/[email protected] => [v1.8.2], see <5> for 1 children (branch 'github.com/sirupsen/[email protected]' level 2)
 │    ├── golang.org/x/[email protected] => [v0.8.0]
 │    ├── github.com/davecgh/[email protected] => [v1.1.1]
 │    ├── github.com/pmezard/[email protected]
 │    └── gopkg.in/[email protected] => [v3.0.1]
 │         └── 1 more ...
 ├── gocv.io/x/[email protected] (go1.13) => [v0.32.1]
 │    ├── github.com/hybridgroup/[email protected]
 │    └── github.com/pascaldekloe/[email protected] => [v0.1.1]
 ├── golang.org/x/[email protected] (go1.17) => [v0.9.0]
 │    ├── golang.org/x/[email protected] (go1.17) => [v0.10.0], see <6> for 3 children (branch 'gobot.io/x/gobot' level 1)
 │    ├── golang.org/x/[email protected] (go1.17) => [v0.8.0]
 │    ├── golang.org/x/[email protected] (go1.17) => [v0.8.0]
 │    └── golang.org/x/[email protected] (go1.17) => [v0.9.0]
 ├── <6> golang.org/x/[email protected] (go1.17) => [v0.10.0]
 │    ├── golang.org/x/[email protected] (go1.17) => [v0.8.0]
 │    ├── golang.org/x/[email protected] (go1.17) => [v0.8.0]
 │    └── golang.org/x/[email protected] (go1.17) => [v0.9.0]
 ├── golang.org/x/[email protected] => [v0.2.0]
 ├── golang.org/x/[email protected] (go1.17) => [v0.8.0]
 ├── google.golang.org/[email protected] (go1.11) => [v1.30.0]
 │    ├── github.com/golang/[email protected] (go1.9) => [v1.5.3], see <7> for 2 children (branch 'gobot.io/x/gobot' level 1)
 │    └── github.com/google/[email protected] (go1.8) => [v0.5.9], see <8> for 1 children (branch 'github.com/golang/[email protected]' level 2)
 ├── <3> gopkg.in/[email protected]
 │    └── gopkg.in/[email protected] => [v1.0.0-20201130134442-10cb98267c6c]
 ├── <9> periph.io/x/conn/[email protected] (go1.13) => [v3.7.0]
 │    └── github.com/jonboulle/[email protected] (go1.13) => [v0.4.0]
 ├── periph.io/x/host/[email protected] (go1.13) => [v3.8.2]
 │    ├── periph.io/x/conn/[email protected] (go1.13) => [v3.7.0], see <9> for 1 children (branch 'gobot.io/x/gobot' level 1)
 │    └── periph.io/x/[email protected] (go1.13) => [v0.1.0]
 └── tinygo.org/x/[email protected] (go1.15)
      ├── github.com/go-ole/[email protected] (go1.12), see <2> for 1 children (branch 'gobot.io/x/gobot' level 1)
      ├── github.com/godbus/dbus/[email protected] => [v5.1.0] (go1.12)
      ├── github.com/muka/[email protected] (go1.14) => [v0.0.0-20221213043340-85dc80edc4e1], see <10> for 10 children (branch 'gobot.io/x/gobot' level 1)
      ├── github.com/saltosystems/[email protected] => [v0.0.0-20230510070731-e096b9afa761]
      │    └── 13 more ...
      ├── github.com/sirupsen/[email protected] (go1.13), see <11> for 3 children (branch 'gobot.io/x/gobot' level 1)
      ├── github.com/tinygo-org/[email protected] (go1.14), see <12> for 1 children (branch 'gobot.io/x/gobot' level 1)
      ├── golang.org/x/[email protected] => [v0.9.0]
      │    └── 4 more ...
      ├── golang.org/x/[email protected] => [v0.8.0]
      ├── tinygo.org/x/[email protected] (go1.15) => [v0.24.0]
      │    └── 6 more ...
      └── tinygo.org/x/[email protected] (go1.15) => [v0.2.0]
           └── 4 more ...

Variant: file for dependency graph

Alternatively a file with the content can be provided.

cd into the package root folder (contains go.mod) and run:

go mod graph > graphfile.txt

deptree -graph=graphfile.txt

Variant: file for module list

Alternatively a file with the content can be provided

cd into the package root folder (contains go.mod) and run:

go list -u -m -json all > upgradefile.txt

go mod graph | deptree -upgrade=upgradefile.txt

Variant: both files used

Relative paths can be used also.

deptree -graph=data/graphfile.txt -upgrade=data/upgradefile.txt

Duplicate occurrence of children

More than one occurrence of an item at different levels of the tree is possible. This occurs very likely for projects with many dependencies (count of imports in go.mod file). deptree handles this in the following way to avoid duplicate information, waste of processing time and possibly circular dependencies:

  • first occurrence of the child will be processed and shown with all sub-children
  • already processed children will be filtered by default
  • the parameter "-a" will show a link to the first processed item (do not filter the line completely)
  • the parameter "-f" forces to process and show each child with all sub-children (stopped at the given depth level)

The option "-f" can lead to hang due to circular dependencies or great amount of work. If this setting is really needed and you note a very long delay, try to set the depth parameter "-d" as minimal as possible.

About

show golang dependence like tree

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •