Effective Go
Details
Core Concepts:
- Formatting (gofmt)
-
Code is auto-formatted; style debates are eliminated by tooling
- Package names
-
Short, lowercase, no underscores; package name is part of the qualified identifier
- Named return values
-
Return values can be named and used as documentation
- Defer
-
Deferred function calls run in LIFO order when the surrounding function returns; used for cleanup (close, unlock)
- Goroutines
-
Lightweight concurrently executing functions; "Don’t communicate by sharing memory; share memory by communicating"
- Channels
-
Typed conduits for goroutine communication; first-class synchronization primitive
- Interfaces
-
Implicit satisfaction — a type implements an interface simply by implementing its methods; enables duck typing
- Error handling
-
Errors are values; idiomatic pattern is
if err != nilat each call site; no exceptions - Blank identifier (_)
-
Discard unwanted values from multi-value returns without compiler error
- Embedding
-
Composition over inheritance; types can embed other types to gain their methods
- Key Proponent
-
The Go Authors (https://go.dev/doc/effective_go)
When to Use:
-
Onboarding new Go developers to idiomatic Go style
-
Code review discussions about Go conventions
-
Establishing team-wide Go coding standards
-
Explaining Go idioms that differ from other languages (e.g. error handling, interfaces)
-
Prompting an LLM to produce idiomatic, production-quality Go code
Current Status:
-
Dated by its own admission — the document opens with: "This document was written for Go’s release in 2009 and is not actively updated. While it remains a good guide for using the core language, it does not cover significant changes to the language (generics), ecosystem (modules), or libraries added since." The Go team has deliberately frozen it (golang/go #28782, still open)
-
It predates the entire modern toolchain era — modules (2018/19) and generics (Go 1.18, 2022) — so its guidance is silent on these topics rather than wrong about the core language
-
Modern complements: the curated Go Code Review Comments (self-described "supplement to Effective Go") and Google’s maintained Go Style series (Guide, Decisions, Best Practices)