repositorypackage
0.0.0-20240731174918-5885030dfc20
Repository: https://github.com/dovholuknf/go-deptree.git
Documentation: pkg.go.dev
# README
go-deptree
This repo exists to create the simplest go program that will output your dependencies in a tree view.
It will run go mod graph
and send the output to go-mod-graph.txt
. The output file will be processed
and rendered as a tree view. The output also excludes dependencies from golang.org
as basically every dependency includes numerous of these modules, leading to dependency tree bloat. There's no way to
change this behavior at this time.
There are a few flags you can pass:
- maxDepth - how deeply to recurse into the deps. defaults to max int
- verbose - just a few extra lines of output
- version - prints the version and exits
- includeVersion - adds the version of the dependency to the tree. defaults to false
- hideSkipReason - suppresses the 'previously seen' and child dependency skip counts
For example, running go run main.go
on this project renders one dependency on testify
and another dependency on github.com/json-iterator/go
to demonstrate some dependencies.
$ go run main.go
github.com/dovholuknf/go-deptree
├─ github.com/json-iterator/go
│ ├─ github.com/davecgh/go-spew
│ ├─ github.com/google/gofuzz
│ ├─ github.com/modern-go/concurrent
│ ├─ github.com/modern-go/reflect2
│ └─ github.com/stretchr/testify
│ ├─ github.com/davecgh/go-spew <previously seen>
│ ├─ github.com/pmezard/go-difflib
│ └─ github.com/stretchr/objx
├─ github.com/stretchr/testify <previously seen - skipping 4 children>
└─ go
└─ toolchain
Installing
To install, execute:
GO111MODULE=off go get -u github.com/dovholuknf/go-deptree
go install github.com/dovholuknf/go-deptree@latest
Running
Defaults
$ go-deptree
github.com/dovholuknf/go-deptree
├─ github.com/json-iterator/go
│ ├─ github.com/davecgh/go-spew
│ ├─ github.com/google/gofuzz
│ ├─ github.com/modern-go/concurrent
│ ├─ github.com/modern-go/reflect2
│ └─ github.com/stretchr/testify
│ ├─ github.com/davecgh/go-spew <previously seen>
│ ├─ github.com/pmezard/go-difflib
│ └─ github.com/stretchr/objx
├─ github.com/stretchr/testify <previously seen - skipping 4 children>
└─ go
└─ toolchain
Max Depth
$ go-deptree -maxDepth=1
Processing with maxDepth: 1
github.com/dovholuknf/go-deptree
├─ github.com/json-iterator/go
├─ github.com/stretchr/testify
└─ go
Include Dependency Versions
$ go-deptree -includeVersion
github.com/dovholuknf/go-deptree
├─ github.com/json-iterator/[email protected]
│ ├─ github.com/davecgh/[email protected]
│ ├─ github.com/google/[email protected]
│ ├─ github.com/modern-go/[email protected]
│ ├─ github.com/modern-go/[email protected]
│ └─ github.com/stretchr/[email protected]
│ ├─ github.com/davecgh/[email protected]
│ ├─ github.com/pmezard/[email protected]
│ └─ github.com/stretchr/[email protected]
├─ github.com/stretchr/[email protected]
│ ├─ github.com/davecgh/[email protected] <previously seen>
│ ├─ github.com/pmezard/[email protected] <previously seen>
│ ├─ github.com/stretchr/[email protected]
│ └─ gopkg.in/[email protected]
│ └─ gopkg.in/[email protected]
└─ [email protected]
└─ [email protected]
Include Version with MaxDepth
$ go-deptree -maxDepth=1 -includeVersion
Processing with maxDepth: 1
github.com/dovholuknf/go-deptree
├─ github.com/json-iterator/[email protected]
├─ github.com/stretchr/[email protected]
└─ [email protected]