Go Introduction

What Go is, why Google built it, and why it has become the default language for cloud infrastructure.

What is Go?

Go (often called Golang) is an open-source, statically-typed, compiled language created at Google in 2009 by Robert Griesemer, Rob Pike and Ken Thompson. It was designed to fix real pain points the creators experienced with large-scale software at Google: slow builds, unclear dependencies, and languages that made concurrency awkward.

Go
package main

import "fmt"

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

Why use Go?

  • Fast compilation — Go compiles directly to a single native binary, often in seconds even for large codebases.
  • Built-in concurrency — goroutines and channels make concurrent programming a first-class, approachable part of the language rather than a bolt-on library.
  • Simplicity — a small, deliberately minimal language spec (no generics-heavy inheritance trees, no exceptions, no classes) — the whole spec fits in a single sitting.
  • Single static binarygo build produces one executable with no runtime or dependencies to install on the target machine — ideal for containers.
  • Excellent standard librarynet/http, encoding/json, crypto/* cover most backend needs without external dependencies.
  • Dominant in cloud infrastructure — Docker, Kubernetes, Terraform, Prometheus and etcd are all written in Go.

How Go programs are structured

Every Go file belongs to a package, and every executable program has exactly one package main with a func main() entry point:

Go
package main               // declares this file's package

import "fmt"               // imports the formatting package

func main() {               // entry point — the JVM-equivalent "start here"
    fmt.Println("Hello!")
}

Compiling and running

Bash
go run main.go     # compiles + runs in one step, for quick iteration
go build main.go   # produces a standalone binary: ./main (or main.exe on Windows)

Unlike Java's JVM bytecode or Python's interpreter, go build produces a native, statically-linked binary — no separate runtime needs to be installed on the machine that runs it.

Real-world example

If you've ever run docker, kubectl, or deployed infrastructure with terraform, you've used Go-built binaries. Its combination of fast startup, low memory footprint and built-in concurrency made it the default choice for cloud-native tooling and backend microservices over the last decade.

Common beginner mistakes

  • Forgetting that an unused import or unused local variable is a compile error in Go, not just a warning.
  • Assuming Go has classes — it doesn't; it has structs and methods attached to types (covered later in this track).
  • Expecting exceptions — Go uses explicit, returned error values instead (also covered later in this track).

Interview questions

Q: What makes Go well suited to cloud infrastructure tools? Fast compilation to a single static binary with no runtime dependency, low memory overhead, built-in concurrency primitives, and a simple deployment story (copy one binary, run it) — all a great match for containers and CLIs.

Q: Is Go object-oriented? Not in the classical (Java/C++) sense — there's no class inheritance. Go achieves polymorphism and code reuse through interfaces and struct composition instead, which tends to produce flatter, less tightly-coupled designs.