Git Product home page Git Product logo

godepq's Introduction

godepq

A utility for inspecting go import trees

Usage of godepq:
  -all-paths=false: whether to include all paths in the result
  -from="": root package
  -ignore="": regular expression for packages to ignore
  -include="": regular expression for packages to include
    (excluding packages matching -ignore)
  -include-stdlib=false: whether to include go standard library imports
  -include-tests=false: whether to include test imports
  -o="list": {list: print path(s), dot: export dot graph}
  -to="": target package for querying dependency paths

Installation:

$ go get github.com/google/godepq

Examples:

List the packages imported:

$ godepq -from github.com/google/godepq
Packages:
github.com/google/godepq
github.com/google/godepq/deps

Find a path between two packages:

$ godepq -from k8s.io/kubernetes/pkg/kubelet -to k8s.io/kubernetes/pkg/master
No path found from "k8s.io/kubernetes/pkg/kubelet" to "k8s.io/kubernetes/pkg/master"

$ godepq -from k8s.io/kubernetes/pkg/kubelet -to k8s.io/kubernetes/pkg/credentialprovider
Packages:
k8s.io/kubernetes/pkg/kubelet
k8s.io/kubernetes/pkg/kubelet/dockershim/remote
k8s.io/kubernetes/pkg/kubelet/dockershim
k8s.io/kubernetes/pkg/kubelet/kuberuntime
k8s.io/kubernetes/pkg/credentialprovider

Track down how a test package is being pulled into a production binary:

$ godepq -from k8s.io/kubernetes/cmd/hyperkube -to net/http/httptest -all-paths -o dot | dot -Tpng -o httptest.png

example output

List imported packages, searching only packages which name starts with "k8s.io/kubernetes":

$ godepq -from k8s.io/kubernetes/pkg/kubelet -include="^k8s.io/kubernetes" -show-loc
Packages:
k8s.io/kubernetes/pkg/kubelet (6908)
k8s.io/kubernetes/pkg/kubelet/token (175)
k8s.io/kubernetes/pkg/util/removeall (108)
k8s.io/kubernetes/pkg/kubelet/nodestatus (764)
...
...
Total Lines Of Code: 133943

Note: This is not an official Google product.

godepq's People

Contributors

alok87 avatar dmitshur avatar evvvvr avatar favadi avatar tallclair avatar zyxar 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

godepq's Issues

Handle cycles from XTestImports

Tests can have a different package from the package they're testing, such as with the stdlib package http / http_test (not to be confused with httptest). The most common reason for this structure is to avoid import cycles,

Currently we include both TestImpors and XTestImports when IncludeTests is set, which can cause the godepq dependency graph to have cycles. Cycles in the graph are problematic for functions like DepthLast.

Readme should use `go get`

The Readme says to install using go install which errors with:

$ go install github.com/google/godepq
can't load package: package github.com/google/godepq: cannot find package "github.com/google/godepq" in any of:
    /usr/local/go/src/github.com/google/godepq (from $GOROOT)
    /usr/local/src/github.com/google/godepq (from $GOPATH)

It should instead use go get or maybe go get -u

Add support for lines of codes per binary

Need to find the lines of codes per binary.
godep shows the packages that were imported.

Please add the support to show the lines of codes imported for a binary.

Add unit tests

The project is currently lacking any tests, and we should fix that.

Add an 'include' flag to specify a regex of packages to include

The default is to include all packages (excluding stdlib & tests). If this flag is specified, then only packages matching the regex would be included in the search, essentially the opposite of the -ignore flag. If both -include and -ignore are provided, then the intersection of the results of both should be used (I believe the order in which they're applied does not matter).

Add support for multiple -from / -to packages

Add support for specifying multiple from / to (source / destination) packages.

Use cases include:

  • Analyzing imports from multiple binaries in the same project
  • Search for imports to a specific project, with multiple packages

Error with CGO

The error happens when CGO is imported.

Error: cannot find package "C" in any of:
    /usr/local/go/src/C (from $GOROOT)
    /var/lib/jenkins/workspace/test/godepq/src/C (from $GOPATH)
    /var/lib/jenkins/workspace/test/godeps/src/C
    /var/lib/jenkins/workspace/test/src/C

I guess we can easily fix by adding "C" to ignore list. But I wonder are there more packages like "C" we should do the same to?

Add an option to cache results for subsequent runs

For large projects, it would be nice to not need to rebuild the dependency graph on each run.

In its simplest form, this could be 2 additional flags for saving the graph to an output file and reading the graph from a saved file.

A more advanced implementation might be able to automate this detecting file modifications, and only rescanning the modified packages.

Vendor support

Currently all packages need to be under the GOPATH, and the tool will not recognized vendored packages.

use -include-stdlib error

godepq -from github.com/go-sql-driver/mysql -include-stdlib

output
Error: cannot find package "golang_org/x/crypto/chacha20poly1305" in any of:
/usr/local/go/src/golang_org/x/crypto/chacha20poly1305 (from $GOROOT)
/home/golang/go/src/golang_org/x/crypto/chacha20poly1305 (from $GOPATH)

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.