Skip to content

Learn Go from Python

A personal, opinionated set of conspect notes for a Python developer picking up Go. The goal is to explain Go on its own terms, with short Python analogies thrown in only when they sharpen the contrast.

All material targets the current stable Go release, Go 1.27.1.

How the notes are organised

Each topic is a numbered folder. Inside each folder, conspects and runnable code examples share one numeric sequence so the reading order is always obvious.

Ecosystem and installation

Language basics

  • Variables and constants — var, :=, const, and iota.
  • Basic types — integers, floats, strings, booleans; no truthiness.
  • Type conversions — explicit T(x), strconv, no implicit coercion.
  • Operators — arithmetic, overflow, integer division; no ternary.
  • Control flow — if, for (the only loop), switch.
  • Functions — multiple returns, named results, variadics, first-class values.
  • Errors — the error value, wrapping with %w, errors.Is/As.
  • Pointers — &/*, nil, new, no pointer arithmetic.
  • Custom types — type definitions vs aliases, underlying types.
  • Structs — fields, literals, zero value, embedding, tags.
  • Arrays and slices — len/cap, append, and the shared-backing gotcha.
  • Maps — keyed lookup, comma-ok, the nil-map trap, sets.
  • Choosing a data structure — slice vs map vs struct vs custom type.
  • Defer — deferred calls, LIFO order, cleanup patterns.
  • Panic and recover — when to panic, recovering in deferred calls.
  • Imports — import paths, aliases, blank and dot imports.

Object-oriented Go

Packages and modules

Concurrency

Text, time and data

The operating system

HTTP with net/http

  • An HTTP server — handlers, ServeMux routing, timeouts, shutdown.
  • An HTTP client — why a 404 is not an error, closing bodies, retries.
  • Middleware — wrapping handlers, recovery, context values.
  • Templates — text/template vs html/template and contextual escaping.
  • Server-sent events — streaming, flushing, dropping slow clients.

Databases with database/sql

Testing

Architecture and conventions

Observability

Third-party libraries

Everything that lands in go.mod. The rest of the book is the language and its standard library; this section is one stack's worth of choices.

Source