Go

Definition

Go (Golang) is a statically typed, compiled language designed for simplicity and readability. Its idioms — captured in Effective Go — favor composition over inheritance, explicit error handling over exceptions, and communicating between concurrent processes over shared memory.


Core Ideas

Formatting & names

gofmt settles formatting debates mechanically (tabs, no line-length limit). Names use MixedCaps, and an identifier’s first-letter case controls visibility (exported = capitalized). Package names are short and lowercase; getters drop the Get prefix; single-method interfaces take an -er suffix (Reader, Writer).

Control & functions

  • No semicolons (the lexer inserts them), so { can’t go on its own line.
  • if/for/switch accept an initialization statement; there’s only one loop keyword, for.
  • Multiple return values are idiomatic — notably value, err.
  • defer schedules cleanup to run at function return (LIFO), keeping open/close logic adjacent.

Composition, not inheritance

There are no classes. Embedding a type into a struct or interface borrows its behavior. Interfaces are satisfied implicitly — a type implements an interface just by having the methods, enabling loose coupling.

Concurrency

“Do not communicate by sharing memory; instead, share memory by communicating.”

Goroutines are lightweight, multiplexed onto OS threads; channels pass typed values between them and synchronize. select waits on multiple channel operations.

Errors

Errors are ordinary values (the error interface), checked explicitly. panic/recover handle truly exceptional cases, not routine control flow.


Relationships


References

  • Effective Go — The Go Programming Language