See: Golang Cheatsheet

Benefits

  • Statically typed — fewer runtime bugs
  • Fast builds, fast feedback loop
  • Small binaries and containers — quick deploys, low memory usage
  • Simple, explicit code; minimal magic
  • Strong standard library — particularly for networking and HTTP

Shortcomings

Modern Go (1.22–1.27)

  • Go 1.22 — per-iteration loop variable scoping (fixes the classic goroutine closure capture bug), range-over-int (for i := range 10), and enhanced http.ServeMux method/path parameter routing
  • Go 1.23 — iter package and range-over-function iterators
  • Go 1.24 — Swiss-table map implementation for faster lookups and lower memory overhead
  • Go 1.25 — sync.WaitGroup.Go() helper for spawning tracked goroutines without manual Add/Done boilerplate
  • Go 1.27 (August 2026) — encoding/json/v2 GA, bringing faster, stricter, streaming-first JSON marshalling and unmarshalling

Concurrency

  • Goroutines, channels, select
  • sync.Mutex, sync.RWMutex, sync.WaitGroup
  • Buffered vs unbuffered channels
  • Production concurrency
  • Context — context.WithTimeout, context.WithCancel, context.WithoutCancel

HTTP / API Frameworks

  • The standard library covers most needs (net/http, http.ServeMux)
  • chi — net/http-compatible router, idiomatic, well maintained
  • Echo — fuller framework if needed

JSON

  • Use json.Unmarshal for one object, json.Decoder for a stream
  • Go 1.27 stabilised encoding/json/v2 for improved performance, stricter defaults, and cleaner streaming APIs

Logging

  • Use structured logging (slog in stdlib) to reduce allocations
  • Add contextual fields (request ID, user, operation)

Testing

  • testify — assertions
    • assert continues on failure
    • require stops the test on failure
  • httpexpect — API tests
  • Run with -race to catch data races

Gotchas

  • A map only grows, it never shrinks — recreate if memory matters (100 Go mistakes)
  • range produces a copy
  • Avoid init()
  • Slowloris / RUDY — set read and write timeouts on HTTP servers
  • Define interfaces on the caller side, not the implementation side
  • Slice gotchas
  • Does Go have subtyping?

Compiling

Resources