typeover
curriculum

Curriculum Types & methods

module 3 of 7

Types & methods

The biggest mental-model change so far. TS object literals carry methods; Go structs don't. Methods are functions with a receiver. Pointers become explicit. Nil exists for a specific list of types.


themes

type Foo struct { ... }. A struct is a typed record — fields and their types, nothing else. No methods on the struct itself (those come next). Field access with .. Struct liter…

9 ready begin →

Methods are functions with a receiver — a special argument declared before the function name: func (r Receiver) Foo() { ... }. Two flavours: value receivers (operate on a cop…

9 ready begin →

&x takes the address of x. *p dereferences p. Pointers in Go are pointers — they're not garbage-collector-hostile, they don't do arithmetic (no p++), and they don't bite.…

9 ready begin →

Every type has a zero value — what an uninitialised variable of that type holds. For numbers: 0. For strings: "". For bools: false. For pointers, interfaces, maps, slices,…

9 ready begin →