Tips for first steps with GO
With this posts I want to highlight few things when staring with GO for new people which sometimes doesn’t seem so straight forward after reading https://golang.org/doc/install.
#1
Install GO’s version 1.6+ there is no point to use any previous versions as with 1.6 version GO added vendor support (experimental in 1.5). What does it mean ? That dependencies are tight to a project not a global GO’s dependency catalog.
If you come from PHP world you can compare it to global command for composer - yes, prior 1.5 and vendor support all go’s dependencies were installed as global.
PS. If you are looking for GO’s dependency management system see glide.
#2
Make your $GOPATH next after installing GO bins - and accept it’s structure, personally it’s not great, but it doesn’t do much harm.
#3
Remember - looping over array / slice does the copy, so:
#4
Accept GO’s “n declared and not used” design concept - GO doesn’t like unused variables, that’s why you’ve seen “_” in previous code. It’s like saying echo "my variable" > /dev/null
PS. I find it a bit annoying when playing with some ideas & code.
#5
Use editor with support for gofmt which will cover almost all issues mentioned here: https://github.com/golang/go/wiki/CodeReviewComments.
PS. Personally I use Atom with go-plus plugin