Giter Site home page Giter Site logo

kylebanks / depth Goto Github PK

View Code? Open in Web Editor NEW
885.0 885.0 66.0 41 KB

Visualize Go Dependency Trees

Home Page: https://kylewbanks.com/blog/visualize-golang-dependency-trees-with-depth

License: MIT License

Makefile 3.39% Go 96.61%
command-line-tool dependency-tree go visualizer

depth's People

Contributors

aaronbee avatar chavacava avatar dgarrick avatar kylebanks avatar ucirello avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

depth's Issues

Does it work for package 'main'?

I tried this on a server program where I want to see the dependency tree starting from the main package. I cd'ed into the same directory where main.go is found and ran depth main. This returned 'main': FATAL: unable to resolve root package.

Of note is that I have many 'local' packages under main, and that is the tree that I would like to see.

Thanks.

Possible performance issue detected in downstream library using `depth`

Hi @KyleBanks,

An issue has been reported recently in a downstream tool, swaggo/swag, which uses depth to calculate required dependencies in order to build valid OpenAPI 2.0 output as a result of parsing code comments in a given folder structure.

Under swaggo/swag#1032 the user @matrixik has exquisitely pointed out, there seems to be a performance issue in swag, which I have narrowed down, with the help of @sdghchj to be a problem with depth.

  1. Could you give a look at the flamegraphs provided under the issue linked and verify the assumption the problem lies in this tool is correct?
  2. Would you be able and willing to help fixing it?

We use swaggo throughout our platform at Compensate in order to build the documentation for all our services.

Thank you,

-Manuel

Output a summary after tree

It would be nice to have a summary printed below the tree, for example:

12 dependencies (8 internal, 4 external).

If the -test flag is set it would also show test-only dependencies:

15 dependencies (8 internal, 4 external, 3 testing).

Handle relative paths from the command line

Currently you have to type the full import path of a package, for example github.com/KyleBanks/depth.

It would be nice to use relative paths like so:

$ pwd 
$GOPATH/src/github.com/KyleBanks/depth
$ depth .
github.com/KyleBanks/dept
...
$ depth ./cmd/depth
github.com/KyleBanks/depth/CMD/depth

depth fails with no output when run from source

I tried to run from source and depth simply exited with no output. Here's what I saw, compared to the output from the last release for my system:

dgarrick@dgarrick-desktop:~/go/src/drive/drive$ go get github.com/KyleBanks/depth/cmd/depth
dgarrick@dgarrick-desktop:~/go/src/drive/drive$ go version
go version go1.8 linux/amd64
dgarrick@dgarrick-desktop:~/go/src/drive/drive$ depth github.com/KyleBanks/depth/cmd/depth
dgarrick@dgarrick-desktop:~/go/src/drive/drive$ ~/Downloads/depth_1.1.1_linux_amd64 github.com/KyleBanks/depth/cmd/depth
github.com/KyleBanks/depth/cmd/depth
  ├ encoding/json
  ├ flag
  ├ fmt
  ├ io
  ├ os
  ├ strings
  └ github.com/KyleBanks/depth
    ├ bytes
    ├ errors
    ├ go/build
    ├ os
    ├ path
    ├ sort
    └ strings

For reference, I'm running Ubuntu 16.04 LTS.

If local Go is different version than Go used to compile `depth`, `tree.Resolve` fails with an unhelpful error message

Hi there!

We've been using depth as a library as a part of https://github.com/fossas/fossa-cli to power our Go dependency discovery. We recently ran into an interesting bug where using a copy of depth compiled with a different (newer?) version of Go than the local Go caused tree.Resolve to fail with cryptic errors like could not resolve package: fmt or could not resolve package: bytes. My suspicion is that this is related to depth's usage of go/build, and some weirdness is going on with importing standard library packages when the Go version changes. See fossas/fossa-cli#63 for our downstream tracking issue.

We're working around this issue by switching to go list parsing instead, but I wonder if this can be resolved within depth itself (maybe by special-casing the standard library packages?). If not, it may be possible to at least give a less cryptic error message by detecting when a resolution error occurs on a known standard library package.

Improve dependency resolution speed with concurrency

Currently depth resolves all dependencies synchronously, which can be slightly time consuming on larger projects or when using -internal and/or -test flags, taking several seconds for large enough dependency trees. This would likely be improved by resolving dependencies concurrently and merging the results at the end.

Will need to add some benchmarks prior to implementing this.

"depth" does not seem to work on any packages other than "depth"

[~] % depth github.com/KyleBanks/conways-gol
'github.com/KyleBanks/conways-gol': FATAL: unable to resolve root package
[~]!% depth github.com/KyleBanks/goggles
'github.com/KyleBanks/goggles': FATAL: unable to resolve root package

It doesn't work on any KyleBanks packages other than "depth" itself, as far as I have tried.

depth crashes when it is unable to resolve an imported package

This may be fine for typical use, but for testing package imports it's particularly troubling. Consider the following:

mypkg 
    - vendoredpkg
         - testdep

When resolving dependencies most package managers do not resolve secondary dependencies that are only required for testing. If mypkg depends on vendoredpkg that's fine, but running depth with -test will try to resolve it's testdep, which likely won't exist.

I think in the case of test packages only, depth could output something like so:

mypkg 
    - vendoredpkg
         - testdep (UNRESOLVED)

Emit "internal" key in JSON output

It would be excellent if the JSON output included a boolean called internal that indicated whether a package is from the standard library.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.