Notes for a Java developer

Go is C with a garbage collector, cheap threads, and a package manager.

No VM. No JIT. No classes, no inheritance, no exceptions. Eleven sections, every example editable and compiled by the real Go toolchain — break them and read the error.

01

Functions & syntax

Types come after names. No void. Multiple return values.

02

Methods & receivers

A method is a function with an extra parameter list glued on the front.

03

Implicit interfaces

The biggest idea in Go. Interfaces are declared by the consumer, not the producer.

04

Closures

Functions are values, they capture variables, and they replace most small classes.

05

Errors are values

No exceptions, no stack unwinding. You return errors and the caller checks them.

06

Memory & escape analysis

The compiler decides stack vs heap. Perf work in Go means "make this not allocate".

07

Goroutines & channels

go f() costs ~2KB. A million of them is normal.

08

defer

finally, but attached to a statement and scoped to the function.

09

Packages, imports & layout

A package is a directory. Capitalization is the access modifier.

10

Debugging & profiling

No JFR, no heap dump. Profiles instead — and they are good.

11

Gotchas

The list worth flashcarding. Each one has bitten everybody.