What is Golang and how to get started?

What is Golang? Where and Why is it used?

Go (or Golang), is an Open Source programming language developed by Google. Go has many use cases like used in building Microservices, Cloud Computing, Web Applications and is used in creating CLI Tools.

Go is a statically typed language and its structures and syntaxes resembles the C Programming Language. Due to Golang's fast startup time, low runtime overhead and the language being platform-independent, it has become very popular language for writing microservices and other use cases. Go is also popular for its concurrency, meaning that it can execute multiple processes at the same time.

Golang uses Goroutines (lighweight processes) and a collection of packages and commands for dependancy management. It was designed to solve problems like slow build times and difficulty writing tools and for cross-language development.

In this blog, I'll be discussing about the Golang and resources to get started with Golang.

History of Go

Golang was created by Google to solve their own software engineering issues and was created as an alternative to the infamous C++. Google started creating Go in 2007, and their goal was to create a programming language that was easier to use and have the useful features of other programming language like C++, Javascript and Python. It was released as a Open Source project by Google in 2009 where people could contribute to the development of Go.

Since then, many new features are being added to the language with the most major update in 2022 where Generics was introduced into the language (major feature of Java).

Due to increasing and fast development of the language, major companies started using the language into their codebase like Netflix, Microsoft, Cloudfare, Docker, Twitch and Dropbox.

Philosophy of Go

The philosophy of Go and the issues fixed through the langauge is quite interesting:

Features of Go:

Some of the useful Go commands:

Go run

It is self-evident from the command, this commands compiles and executes the code simulataneously.

go run filename.go 

Go build

This command compiles the code and is stored in a executable file.

go build filename.go 

Go get

It integrates with GitHub to import libraries defined by other users in GitHub.

go get github.com/libname 

Go fmt

This command is really a useful and a interesting feature of Go. This command formats a file with indents and newline characters to make it readable.

go fmt filename.go 

Unformatted File


package main
import "fmt"
func main(){
fmt.Println("Sample Addition")
a:=5
b:=4
c:=a+b
fmt.Println(c)
}
            

Formatted File with go fmt


package main

import "fmt"

func main() {
    fmt.Println("Sample Addition")
    a := 5
    b := 4
    c := a + b
    fmt.Println(c)
}
            

You can see how the commands formats the code to make more readable.

What is Go used for?

Go is used for many useful purposes:

How to learn Go

Go is comparetively a easy language to learn. People might find it hard to learn the concepts of Goroutines, Go Channeling and Concurrency as they are the hte hardest concepts of the language and also the best feature of the language.

Hey!! Don't worry, the best features always takes effort to master.

The best ways to learn any language is through books and online documentation. Many don't realise and don't come out of the "Tutorial Hell". People often end up watching too many videos, get confused between concepts and end up procrastinating and finally quit learning the language.

As a person who learns from Books and Online Docs, I could by far say that Golang has one of the best online documentation ever when compared to online docs of any language. They provide concept wise lessons and a IDE interface for learners to execute and see the output of their own.

The docs are divided into two parts: A Tour of Go and Effective Go.

A Tour of Go is from the basics and teaches all the syntaxes one by one which goes from explaining values and datatypes to teaching about Concurrency.

Effective Go teaches us methods to write clear and idiomatic Go Code.

Here are the links to Docs:

Books to learn Golang:

This by far the best book to learn Go

Thank You for reading this blog