Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What's the principle of operation? #3

Closed
dmitshur opened this issue Apr 7, 2016 · 3 comments
Closed

What's the principle of operation? #3

dmitshur opened this issue Apr 7, 2016 · 3 comments

Comments

@dmitshur
Copy link

dmitshur commented Apr 7, 2016

Hi there, I'm trying to better understand the purpose of this command.

From the README:

It aims to provide a faster alternative to "go list all" to list available packages for import.

Are there any benchmarks comparing the performance?

Assuming it's faster, how does it achieve that, and what's the reason such an optimization could be not sent upstream into cmd/go so that go list all is equally fast?

Thanks!

@dmitshur
Copy link
Author

dmitshur commented Apr 7, 2016

I tried it on my workspace with many packages, and it's indeed much faster:

$ time go list all > /dev/null

real    0m7.265s
user    0m6.202s
sys 0m2.686s

$ time gopkgs > /dev/null

real    0m0.027s
user    0m0.009s
sys 0m0.015s

However, it does not appear to produce correct results. Many packages are missing.

$ go list all | wc -l
    4702

$ gopkgs | wc -l
    1689

@tpng
Copy link
Owner

tpng commented Apr 8, 2016

The difference of go list all and gopkgs is that go list all looks for go packages in your $GOPATH/src while gopkgs looks in your $GOPATH/pkg.
As a result of this, only importable packages that have been installed (either by go get or go install) are listed by gopkgs.

Why go list all is much slower is because it has to read the source files while gopkgs only depends on the filepath.

@dmitshur
Copy link
Author

dmitshur commented Apr 8, 2016

That makes sense, thanks for explaining (and I think it's worth putting this in doc.go/README)!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants