The Go is a programming language was created by Google it's similar to C and not an object-oriented language, so a certain degree of simplicity exists. One of the advantages is a compiled type language which makes it faster than interpreted languages like Python. Also supports concurrent programming in language level through Go routines. This feature makes it very useful in networking and system level applications and also very popular in building microservices.

First Steps

Let's install Go in our Linux distribution, first we go to the official website https://golang.org for downloading the archive that contains the binary files, after that we unpack the archive to directory /usr/local, this directory is used to install independent software that is not managed from OS package systems, then we extract the archive with the following command.

tar -C /usr/local -xzf go1.7.4.linux-386.tar.gz

If you see any problem with permissions, run the previous as sudo user. Then, using an editor like nano we open file /etc/profile to set up the paths, that is necessary, shell to know where are the executable files to Go lang. This can be done by appending at the end of the file /etc/profile the following command

export PATH=$PATH:/usr/local/go/bin

To continue the new changes to take place we have to refresh file .profile with the following

source /etc/profile

if we write in command line the word go, now we see all related commands for compile go programs

The commands are:

build compile packages and dependencies clean remove object files doc show documentation for package or symbol env print Go environment information

To make a test let's create a new file

touch test.go

append the following code

package main
func main() {
     println("Hello", "world")
}

we compile and run the go program with go run test.go

which outputs

Hello world

Concurrency

One of the highlights of this language is the ability to create programs with concurrency, that means parts of this can be executed in a different order or at the same time. These subroutines are named goroutines and we want subroutines in this way we have to use the word go in front of the name.

package main
func foo(n int) {
    .....
}

func main() {
     go foo(0)
     println("Hello", "world")
}

In more advanced concepts goroutines can communicate during the execution with the channels.

microservices architecture

The advantage this language to implement the concept of concurrency in combination with the features of creating HTTP server and clients with by importing the following package import "net/http" make this perfect candidate for building microservices. There are already frameworks to support this like gokit.io 

conclusion

One of the most important part of this language is the concept of concurrent asynchronous programming is intergated natively to the language. Also the golang can intergrate easily that are written in C. If need help from a golang programmer contact us.