One of the most confusing parts of starting Go was learning the project
layout or what Go calls the workspace. It’s changed a little bit in past
releases (eschewing $GOROOT etc) but the confusion I think remains
if you come from other languages and tools.
Internalize these things:
- Your code will go in a folder next to all the libraries you download.
- You probably cannot put your Go code next to your Java/Python/Ruby/Javascript/… unless you luck out on naming conventions that you’ve already started.
- If you are starting out and you don’t put stuff in
~/binthen just set$GOPATHto your home. - If you don’t like that last rule, just create
~/gocodeand set$GOPATHto that. - You probably should not put your Go code in Dropbox.
You also do not need to create a github.com account to put your projects
in ~/gocode/src/github.com/{username}/hello_world. You can just go
ahead and start your project. It’s just a namespace. If something else
needs github.com/{username}/hello_world then it will import it. If it
can find it in the GOPATH then it will work. That’s all this is.
When I started Go, I was worried that I was polluting system paths by
starting projects in $GOPATH/src/github.com/{my_username}. You’re not. Don’t
think about it.
I can’t put my crap code next to the likes of Docker!
It’s impostor syndrome. Just start your project. Just do it.