Hello guys, today I will write an article about how to install golang in elementary os hera. Golang is Go Programming Language. I use JavaScript everyday but because many people says that Golang is really fast, is that true? so now to find the answer, let’s try to install Golang first then learn about it.

How to Install Golang

Because Golang is getting more populer today, so I would like to start learn it now.

So here is the tutorial how to install golang in Elementary Os Hera :

Download Go

For the first time, We have to download Go at golang.org. Choose the latest stable version. When I write this article, the current stable version is 1.13.5.

After download success, move it to /usr/local.

Or you can download it directly with using command line

1
2
$ cd /usr/local
$ sudo wget https://dl.google.com/go/go1.13.5.linux-amd64.tar.gz

Extract it

We need to extract it

1
$ sudo tar xzvf go1.13.5.linux-amd64.tar.gz

Configure Path

We have to edit the environment to make go command is available in our terminal.

1
$ sudo nano ~/.bashrc

Now add this code line into .bashrc at very bottom line

1
2
3
export GOROOT=/usr/local/go
export GOPATH=$HOME/Projects/Go
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH

Note:

  • $HOME/Projects/Go is the location for Go projects.

Then run this command below

1
$ source ~/.bashrc

Check Version

Now we check the Go version to make sure Golang is successfully installed in our system.

1
$ go version

Create Hello World

Let’s try to create our first hello-world program using Go.

  • Create new project

    1
    2
    $ cd /home/YOUR_USERNAME/Projects/Go
    $ mkdir hello
  • Go to hello directory

    1
    $ cd hello
  • Create new file

    1
    2
    $ touch test.go
    $ nano test.go
  • Now paste this code and save it

    1
    2
    3
    4
    5
    package main
    import "fmt"
    func main() {
    fmt.Println("hello world")
    }
  • Run it

    1
    $ go run test.go

Yeah, everything is done. Now look at your terminal, you will be able to see a hello world text in it.

Benefit using Golang

I’m a NodeJS user, so why I must learn Golang? What is benefit of using Golang? Well, this is actualy a hard question to answer. I’m also still new to learning Golang, but so far I have already read many literatures about Golang by searching through Google, and with some of my knowledge, here is the benefit of using Golang :

Fast in Performance

Comparing with other interpreted language like Ruby, PHP, and NodeJS, Golang is much faster because Go is compiled to machine code. Golang is more eficient because Golang is Single Execution and doesn’t need virtual runtime, also Golang is don’t have Generics and Dynamic Libraries.

Scalability and Concurrency

Golang has Goroutines is a methods or functions that run in parallel with another methods or functions. So with this features, Golang has more ability to handle thousands of request simultaneously.

Comparing with NodeJS which is still use single thread, you will more harder to handle big concurrency process because sometimes the big event-loop is blocking your system. I know there is a way to solve this problems, but I could say that with using Golang you will be more easier to handle this.

Community

Comparing with NodeJS, of course Golang has more smaller than NodeJS community. But infact, they always increasing every year. So this means that Golang is having future. Also with community, you will not harder to solve your problems.

Company using GO

Following the technology from big company, maybe this is a good idea to make sure is Golang are ready for production or not. By the way, there so many of big company has been successful to use Golang as backend of their core bussiness system. These big companies are :

  • BBC
  • Google
  • Uber
  • Heroku
  • Medium
  • Docker
  • Intel
  • Basecamp

When I must use Golang ?

Golang is having best performance and good for build a large scale application for backend of core systems. I recommend you to use Golang when you are in big projects only. For small or medium projects you can go with NodeJS. Why? because many people says that it’s requires more time to develop an application with Golang. NodeJS is more rapid than NodeJS, but it’s all depend on your situations and conditions.

Is it hard to learn Golang ?

Learning the basic or fundamental of Golang actualy is very simple, but if you are comes from Java or C#, you will get a little bit confusing because Golang has no Generics and Dynamics Libraries. But as time goes by, I’m sure you will get used to it.

How is Golang for today ?

Golang is getting popular now, because many people today using gohugo cms for their blog or portfoliio. So do I, I learn Golang from the fundamentals because I want to try to build gohugo cms for my personal portfolio.

For someone who never heard about gohugo, gohugo is the static html generator based on Golang, same as Hexo which is based on NodeJS. There is many pros and cons about these two cms, but for scaling, you better to use gohugo. If you are having more than 10K articles, using Hexo could lead you with javascript heap out of memory, but with gohugo, you can scale your articles for more than 100K and it’s deploy process time still very fast which is just in seconds.

Conclusion

Sorry, this article maybe not relevan with the topic of how to install Golang in elementary Os. I’m too much talk about Golang information than the tutorial itself. But actualy installing Golang in Elementary Os is very easy, with just a simple tutorial in above article, we have Golang installed in our system now.

If you are still curious about Golang, you can learn it more detail at Golang Documentation.

Thank you for your time to read my article.