About Me
- github: https://github.com/haya14busa
- twitter: https://twitter.com/haya14busa
- blog: http://haya14busa.com/
About This Repository
Feel free to open new issue :)
:zap: List Go packages FAST by using the same implementation as goimports
License: Other
Feel free to open new issue :)
Every couple of months I notice that gopkgs
stops listing Go's packages such as "time", "os", "net/http" and others.
I think that I was able to pinpoint why that thing happens. Inside the codebase, there are usages of the build.Default.GOROOT
(from go/build
package):
Line 516 in 29d3292
If the host machine does not have the GOROOT env. variable set (it's not a requirement to be set), then it uses values that are written to the binary file itself. Those values may be different if compiled on different host machines or if you use homebrew and upgrade the Go to a different version.
To test this theory I've written a small program that displays the build's default context.
package main
import "fmt"
import "go/build"
func main() {
fmt.Printf("%+v\n", build.Default)
}
I've built the same program on two different hosts with two different Go versions installed. One is the Linux machine (inside of a docker container) and the other one is my host machine which is the macOS 10.13.3.
I've built the from_linux
binary inside of a Docker container for the macOS, then I run it from the macOS. I've also built the same binary on the host machine itself.
Running both binaries locally, it's visible that GOROOT is different.
The same thing happens when you are using homebrew to upgrade go. If you built the gopkgs
on version Go version 1.11.11
and then upgrade Go to version 1.12.6
, it will not list any of those Go related packages because the folder does not exist anymore. It was deleted by the homebrew. This is what happens to me every few months.
And of course, setting the GOROOT env variable fixes the problem:
In my environment, some packages are duplicate.
For example:
> gopkgs | grep isatty
github.com/mattn/go-isatty
github.com/junegunn/go-isatty
github.com/mattn/go-isatty
github.com/mattn/go-isatty
It seems that vendored packages are shown multiple times even if -short
or no option.
> cd ~/.go/src
> fd go-isatty
github.com/mattn/go-isatty
github.com/junegunn/go-isatty
github.com/derekparker/delve/vendor/github.com/mattn/go-isatty
github.com/fatih/color/vendor/github.com/mattn/go-isatty
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.