# Go Language Reference
## Languages — The Codex Coding
**URL:** https://thecodex.expert/coding/languages/go/
**Type:** language-reference | **Confidence:** high | **Last verified:** 2026-06-01

## CANONICAL DEFINITION
Go (Golang) is a statically typed, compiled, garbage-collected programming language designed at Google for simplicity, fast compilation, and built-in concurrency via goroutines and channels — used for cloud infrastructure, web services, and CLIs at scale.

## QUICK FACTS
- **Created:** March 2012 (1.0); by Robert Griesemer, Rob Pike, Ken Thompson at Google
- **Current:** Go 1.26 (August 2024)
- **Typing:** Static, strong, inferred
- **Execution:** Native compiled (gc compiler, self-hosting since 1.5)
- **Memory:** Garbage collected (tricolour concurrent mark-sweep, low-latency)
- **Concurrency:** Goroutines + channels; M:N scheduler (G/M/P model)

## CRITICAL NOTES
- **No classes** — structs + methods; composition via embedding; no inheritance
- **Interfaces are implicit** — no `implements`; satisfied by having the right methods
- **Goroutines are NOT OS threads** — M:N scheduled; ~2KB stack each; millions possible
- **No exceptions** — errors are explicit return values; always check `if err != nil`
- **Generics added in Go 1.18** (March 2022) — type parameters in square brackets
- **Loop variable capture fixed in Go 1.22** — pre-1.22 for-loop goroutines all shared the same loop variable

## GOROUTINES AND CHANNELS
- `go fn()` — launch goroutine
- `make(chan T)` — unbuffered channel (synchronous)
- `make(chan T, n)` — buffered channel (async up to n)
- `<-ch` — receive | `ch <- v` — send | `close(ch)` — close
- `select` — multiplex channels; picks ready case uniformly at random
- `range ch` — receive until closed

## CONCURRENCY PATTERNS
- Worker pool: fixed goroutines, jobs channel, results channel
- Timeout: `select { case v := <-ch: ... case <-time.After(d): ... }`
- Cancellation: `context.WithTimeout`, `context.WithCancel`, check `ctx.Done()`
- Mutex: `sync.Mutex` for shared mutable state
- WaitGroup: `sync.WaitGroup` to wait for goroutine completion

## ERROR HANDLING
- Functions return `(T, error)` as last return value
- Check: `if err != nil { return ..., err }`
- Wrap: `fmt.Errorf("context: %w", err)` (Go 1.13+)
- Inspect: `errors.Is(err, target)`, `errors.As(err, &target)`
- Sentinel errors: `var ErrNotFound = errors.New("not found")`

## VERSION MILESTONES
- 1.0 (2012): stable release
- 1.5 (2015): self-hosting compiler; concurrent GC
- 1.11 (2018): modules (go.mod)
- 1.13 (2019): error wrapping
- 1.18 (2022): generics
- 1.21 (2023): slices/maps stdlib packages; min/max builtins
- 1.22 (2024): loop variable per-iteration fix
- 1.23 (2024): range over functions (iterators)

## NOTABLE PROJECTS IN GO
Docker, Kubernetes, Terraform, Prometheus, Grafana, CockroachDB, etcd, Hugo, Caddy

## SOURCES
- Go spec: go.dev/ref/spec
- Donovan & Kernighan (2015): The Go Programming Language
- Go memory model: go.dev/ref/mem

*The Codex Coding — thecodex.expert/coding/ — Free forever — Mumbai, India*
