on *nix systems (possibly on windows with bash tools like msysgit or cmder), to see what packages I have installed, I can run:
history | grep "go get"
But thats messy output. For whatever reason I decided to see of i could clean that output up a little so i made an alias for this command:
history | grep 'go get' | grep -v ' history ' | sed -e $'s/go get /\\\\\ngo get /g' | grep 'go get ' | sed -e $'s/-u //g' | sed -e $'s/-v //g' | sed -e $'s/ &&//g' | grep -v '\\\n' | egrep 'get [a-z]' | sed -e $'s/go get //g' | sed -e $'s/ //g' | sort -u
please don't ask why I did this. Challenge maybe? Let me explain the parts
history
the history
grep "go get"
grep over history and only show lines where we went and got something
grep -v " history "
and remove times when we have searched for "got get" in history
sed -e $'s/go get /\\\\\ngo get /g'
Now we take any instances of "go get " and shove a new line in front of it. Now they're all at the beginning.
grep "go get "
filter only lines that now start with "go get"
sed -e $'s/-u //g'
and sed -e $'s/-v //g'
remove flags we have searched for. You could possibly leave them in but may get duplicates when output is done.
sed -e $'s/ &&//g'
some times we install with multiple commands using '&&' so lets remove them from the ends of the line.
grep -v "\\\n"
my output had other lines with newlines printed I didnt need. So this got rid of them
egrep "get [a-z]"
make sure to get properly formatted go package urls only.
sed -e $'s/go get //g'
remove the "go get " text
sed -e $'s/ //g'
strip any whitespace (needed to filter out duplicates)
sort -u
now sort the remaining lines and remove duplicates.
This is totally untested on other systems. Again, I am quite sure there is a cleaner way to do this. Just thought it would be fun to try.
It would also probably be more fun to make a go ls
command to show the actual packages you explicitly installed. But thats a lot more work. Especially since i'm only still learning Go.
Output:
> gols
code.google.com/p/go.crypto/bcrypt
github.com/golang/lint/golint
github.com/kishorevaishnav/revelgen
github.com/lukehoban/go-find-references
github.com/lukehoban/go-outline
github.com/newhook/go-symbols
github.com/nsf/gocode
github.com/revel/cmd/revel
github.com/revel/revel
github.com/rogpeppe/godef
github.com/tpng/gopkgs
golang.org/x/tools/cmd/goimports
golang.org/x/tools/cmd/gorename
gopkg.in/gorp.v1
sourcegraph.com/sqs/goreturns