Introduction to GoLang

GoLang is an open source language developed and backed by internet giant Google. GoLang is famously known as GO and that is how we are going to refer to in future. In 2007, Robert Griesemer, Rob Pike and Ken Thompson at Google started with experiment to develop a language that will have minimal of features, but will cater most of the use cases. Beside this their idea was to overcome some of the hurdles in development, build and deployment of code written in C (and also of any other languages). GO was officially released in 2009, with latest version GO 1.5 releasing in August 2015. GO’s popularity is growing rapidly and is used by many companies like MongoDB, CloudFlare, BBC etc. Click here to know more on who are using GO and for what purposes.

But GO’s, rapidly growing popularity is not the only reason, why one should learn GO, but it is the features and the design of the GO language.

Features:
1. Is Statically type language, this means that compiler will try to check the type of assignment and complain in case of mismatch. Go though support dynamic type with help of interface, but not in truly an polymorphism way.
2. Fast compilation of code
3. GO is designed in a way were their are not too many options, restricting the number of ways in doing the same thing. This also brings in the ease of reading code written by someone else.
4. GO, also builds in the runtime code required for execution along with the GO final execution file, though this makes the final binary large in size, but avoid the hurdle of installing and configuring GO on machine where code is going to be executed.
5. GO, as a language have best support for Concurrency built-in.
6. GO also have various other tools for formatting, generating docs, testing and benchmarking of the code written
7. Supports deployment on various OS.

Along with the key features stated above there are many more that should excite a developer to learn this new language.

Hello Playground !!!

GO, was developed with the idea to promote simplicity and so far stands to it. We don’t need to install GO on local machine to try and get started with. Visit http://play.golang.org/ online tool for GO. As soon as you launch this URL, but default you will see code for Hello Playground our first program.
Let us try to understand our first program and thereby get introduce to the GO language.

First Go Program-Hello Playground

First Go Program-Hello Playground

1. First line of the code is “package main”, just like any other language package is used to group together various code files.
2. Import “fmt”, statement to import fmt package required for formatted I/O operation like printing and scanning.
3. func main () entry point for the execution. You can have multiple files in the package main, but only one file can have func main defined in it.
4. fmt.Println(“Hello, playground”), call to Println method in fmt package to print “Hello Playground”

Please note, there are some limitation to the use of playground:
1. Can run only one file at a time.
2. Cannot try file I/O operations.
3. Limitation on execution time, CPU and memory usage
So in case if you want to install GO on your local machine click here.

Conclusion:

Today we got introduce to the GO, one of the most rapidly growing language. We saw our first GO program and got familiar with it. Also we looked at the online tool Go Playground to get quickly started with GO. Though GO follows C like syntax, but just like any new language GO too has its own way of doing things like variable declaration, func calling and so on. In next few blogs to follow we are going to learn the basics of GO and understand how things are done in GO.