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

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. pom.xml in Java)

Setup

Used Atom editor with go-plus plug-in. Other plug-ins I am using: go-debug, linter-golinter, linter-govet, go-signature-statusbar, go-rename, go-def, go-findreferences, linter-golint and gotests

First Package (aka library) & Command

First test for the example package

Learning

  • If you have installed Go in a non-default directory then you need to set GOROOT environment 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)

Good read

Like what you read? Give Aravind R. Yarram a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.