Getting started with Go Language
Learning Go was in my to-do list for 2016. Finally I found some free time to begin that journey yesterday.
Having worked on C/C++, Java and Scala, I am really impressed that the following tool chain is built into Go
- Workspace for organizing multiple projects/packages
- Package management
- Unit testing (Runner, Code coverage, Race-condition detection)
- Doc gen
Everything that is needed to build the app comes from the source code files. No additional meta data required to be specified in other files (for e.g.
First Package (aka library) & Command
First test for the
- If you have installed Go in a non-default directory then you need to set
GOROOTenvironment variable. Otherwise you will see the following
error: go: cannot find GOROOT directory: c:\go
- There are either package objects (placed under pkg) or executable commands (placed under bin)
- Executable commands should always use package main
- You can’t have more than 1 main() function within a single package (say package main)