Skip to content

Introduction

History

The Go programming language was conceived in late 2007 as an answer to some of the problems we were seeing developing software infrastructure at Google. The computing landscape today is almost unrelated to the environment in which the languages being used, mostly C++, Java, and Python, had been created. The problems introduced by multicore processors, networked systems, massive computation clusters, and the web programming model were being worked around rather than addressed head-on. Moreover, the scale has changed: today's server programs comprise tens of millions of lines of code, are worked on by hundreds or even thousands of programmers, and are updated literally every day. To make matters worse, build times, even on large compilation clusters, have stretched to many minutes, even hours.

Go was designed and developed to make working in this environment more productive. Besides its better-known aspects such as built-in concurrency and garbage collection, Go's design considerations include rigorous dependency management, the adaptability of software architecture as systems grow, and robustness across the boundaries between components.

Source

Pain points at Google:

  • slow builds
  • uncontrolled dependencies
  • each programmer using a different subset of the language
  • poor program understanding (code hard to read, poorly documented, and so on)
  • duplication of effort
  • cost of updates
  • version skew
  • difficulty of writing automatic tools
  • cross-language builds

Gopher

Original Gopher
Funny Gophers from different projects

Projects using Golang

  • Docker
  • Kubernetes
  • Gogs
  • InfluxDB
  • Snappy
  • Minio
  • Mattermost
  • OpenShift
  • Pocketbase

Key Benefits

Deploy across platforms in record speed

For enterprises, Go is preferred for providing rapid cross-platform deployment. With its goroutines, native compilation, and the URI-based package namespacing, Go code compiles to a single, small binary—with zero dependencies—making it very fast. Leverage Go’s out-of-the-box performance to scale with ease

Tigran Bayburtsyan, Co-Founder and CTO at Hexact Inc., summarizes five key reasons his company switched to Go:

  • Compiles into a single binary — “Using static linking, Go actually combining all dependency libraries and modules into one single binary file based on OS type and architecture.”
  • Static type system — “Type system is really important for large scale applications.”
  • Performance — “Go performed better because of its concurrency model and CPU scalability. Whenever we need to process some internal request, we are doing it with separate Goroutines which are 10x cheaper in resources than Python Threads.”
  • No need for a web framework — “In most of the cases you really don’t need any third-party library.”
  • Great IDE support and debugging — “After rewriting all projects to Go, we got 64 percent less code than we had earlier.”

The good

  • Simplicity
  • Fast
  • Built-in Build and Package Management
  • Type Switch
  • Concurrency
  • Values vs Pointers

Simplicity

Go aims to be a simple programming language. It has a minimal set of language constructs. It makes simple project and package module structures possible. The visibility control only relies on public or private exports. Data Structures can be easily defined by just a few possibilities: Structs, Maps, Arrays. Testing is very easy in Golang, thanks to built-in commands and libraries.

Fast

Go programs being compiled down to machine code, and having a static type system, makes it really fast during the execution. Also, the startup time is much less than to something like Java or any JVM language.

Built-in Build and Package Management

Golang has a built-in build and package management what makes it easy to maintain packages. This eliminates the requirement for a third-party package and build management systems like Gradle, Maven, make, etc., and makes life so much easier for developers.

Type Switch

In Golang it's possible to do easy type switches instead of doing expensive operations like instanceof (Java).

Visibility Control

Visibility Control can be managed by using public or private variables, constants, and methods.

Concurrency

Golangs concurrency model is really simple. Goroutines make it possible to start a managed concurrency model.

Values vs. Pointers

Go supports pass-by-value and pass-by-reference.

The bad

  • No Constructors
  • Error Checking
  • Confusing Design
  • No Generics
  • (No Inheritance)

No constructors

In Golang there are no constructors, you have to write constructors for structs by yourself.

Error Checking

Each and every error has to be checked.

Confusing Design

There are some patterns, like the public/private concept and error handling and many more, which can confuse the first time.

No Generics

This isn't true anymore :)

No Inheritance

There is a lot of rumor about Golang, that it does not support inheritance. This is not really correct, it actually has a concept for that, which is called embedding. But it just differs from known concepts about inheritance.

Which IDE to choose?

Installation

To install Golang simply see: go.dev / Download and install

Mac users can install golang with brew: brew install go

Windows users can install golang with Chocolatey: choco install golang

Hello World!

main.go
1
2
3
4
5
6
7
package main

import "fmt"

func main() {
    fmt.Println("Hello World!")
}

To build and run it, simply run: go run main.go

Playground

You can always use Go Playground to play around with go or just use it as "REPL" editor.

Is it "Go" or "Golang"?

Usually you say: "Go".

This is the official name of the programming language.

The only reason why some people say "Golang" is, because it helps to identify the term more as programming language and to use it as google query. Also the first domain was reserved for golang.com but now it became go.dev.

Books and Sources