Go

Introduction to Go

Go was created at Google in 2009, explicitly to fix pain points its creators had with C++ at scale: slow builds, hard-to-manage dependencies, and concurrency that was easy to get wrong. The result is a language that looks almost nothing like C++'s answer to those problems — smaller, more opinionated, and built around one specific idea: make it easy to write software that does many things at once, correctly.

Quick reference
What it is
A compiled, statically-typed, garbage-collected language with built-in concurrency support, a fast compiler, and a deliberately small feature set.
Mental model
If C++ says "give the programmer every tool and trust them," Go says "give the programmer fewer tools, chosen carefully, so any Go codebase looks roughly like any other."
Key numbers
Files use the .go extension; go build typically compiles in seconds even for large codebases — a deliberate design goal, not an accident.
Reach for it when
Building networked services, CLI tools, or anything needing straightforward concurrency — less commonly the first choice for hard real-time or deeply resource-constrained embedded targets (see this domain's closing chapter for exactly why and where it still fits).

Go's design philosophy, by contrast

C / C++Go
Memory managementManual (C) or RAII/smart pointers (C++)Automatic garbage collection — no free, no delete
Error handlingReturn codes (C) or exceptions (C++)Explicit multi-value returns, checked by convention — no exceptions at all
Object-oriented featuresNone (C) or classes/inheritance (C++)Structs with methods, but no inheritance — composition and interfaces instead
ConcurrencyOS threads, manual synchronizationGoroutines and channels, built directly into the language
Compile speedCan be slow on large C++ codebasesA deliberate, explicit design goal — typically very fast

None of this makes Go strictly "better" — it's a different set of tradeoffs, optimized for different priorities than C or C++'s. Every chapter in this domain calls out exactly which tradeoff is being made and why.

A first program, line by line

package main

import "fmt"

func main() {
    fmt.Println("Hello, Go!")
}
package main
Every Go file belongs to a package — main specifically marks this as a standalone, runnable program rather than a reusable library.
import "fmt"
Brings in the "format" package, Go's standard library equivalent of C's <stdio.h> — fmt.Println is the direct analog of printf.
func main()
Exactly like C's main — the entry point every Go program starts running from. No return type, no arguments needed for the simple case.
No semicolons
Go statements don't end in ; in normal source — the compiler inserts them automatically based on line breaks. This is a real, visible difference from every C-family syntax you've seen so far.

The toolchain

go run hello.go     # compile AND run in one step — great for quick iteration
go build hello.go    # compile to a binary named "hello", don't run it
./hello               # run the compiled binary
go fmt hello.go       # reformat the file to Go's standard style, automatically

go fmt is worth calling out specifically — Go ships an opinionated auto-formatter as a core tool, and the entire Go ecosystem uses it by convention. There's no equivalent debate over code style that C/C++ projects often have, because the tooling settles it.

A map of what's ahead

Real-world applications

Gotchas

Field notes