Just started with go and I’m trying to wrap my head around the tools that exist with go. I’m thinking about things such as golint, govendor and guru and the likes. So far I’ve been working on one isolated project but it’s going to branch out to be a general library several other projects will be depending on. That’s when the layout starts looking pretty odd to me, for instance I’m using “goimports” in emacs to format my code, and thus I need to have it in my path somehow. What I’ve started doing is “go getting” the tools I need and then copy the binaries (and in the case of oracle.el also the source file) to $GOROOT.
My gut feeling is that I’ve misunderstood how “the right way” to do things is for go. So, can someone please use a few minutes to explain to me The Right Way to do things in go?
I don’t know what “the right way” exactly is either, and I never had this problem, since I use Atom and it installed all dependencies for me. But if I understand your problem correctly, you need to have your tools in your path. That seems like it is solved by the recommendation I’ve read somewhere (I think it was the Getting Started guide on golang.org) to have your $GOPATH/bin in your path, which makes it easy to just compile and run your programs - and automatically has your tools available then too.
A common way of handling this is to have GOPATH=~. You then keep your source in ~/src and binaries get installed to ~/bin. Add ~/bin to your PATH and you’re good to go.
Coming from perl/java/python/… it’s a bit of a new way of thinking for me about the project setup and the development environment. More used to each repository being completely independent and the dev tools being installed globally. Your answers and following up with reading this blog post (and the video) really helped me understand the “go way” of doing it.
I’ve now got some problems with govendor but I’ll wrestle it for a while before asking for help again.
My go install is in $HOME/go. All that line does is making sure $HOME/go/bin is in my path, followed by $HOME/bin.
edit: It looks like you’ve unpacked the Go distribution from golang.org into $HOME/go. Don’t do that. Follow the instructions on the website and you won’t have to set $GOROOT. If you have to set $GOROOT, you’ve made a mistake somewhere.