Loops, functions and data

One loop shape, and many data shapes. These lessons cover for and range, functions with several results, the error as the second one, and pointers. Then come the data the language is built around: arrays, slices with the array behind them, maps with their internals, strings as bytes and as runes, and the fmt verbs that print them. The part ends on structs and methods.

2.1 Loops, range and labels the four shapes of for, range over slices, strings, maps and integers, labels, and break outside a loop Open 2.2 Functions, several return values and closures parameters, several results, named results, variadic functions and a closure that captures Open 2.3 Errors as values the error interface, returning an error, errors.New, fmt.Errorf, errors.Is and the nil check Open 2.4 Pointers, nil and the address of a value & and *, new, a pointer field, value against pointer arguments and the nil pointer that panics Open 2.5 Arrays and fixed-size buffers the length in the type, literals, copy and comparison, passing an array, nested arrays and the wrong-size error Open 2.6 Slices and the array behind them make, literals, append, len and cap, subslices as views, a slice over an array and slices.Clone Open 2.7 append, capacity and shared backing arrays the three-word header, growth, the full slice expression, copy, the aliasing bug and make len against cap Open 2.8 Maps: lookup, comma-ok and iteration make and literals, missing keys, comma-ok, delete, random iteration, sorted keys, the nil map and comparable keys Open 2.9 Map internals, hashing and growth buckets, hashing, load factor, growth, the random start of a range and the cost of a lookup Open 2.10 Strings, bytes and runes a string is a byte sequence, indexing, concatenation, strings.Builder and the conversion to []byte and []rune Open 2.11 UTF-8, runes and the strings package runes, UTF-8 widths, len against RuneCountInString, strings.Fields and a word count Open 2.12 fmt, verbs and a text table the verbs, width and precision, Sprintf, Fprintf and a table aligned by the format Open 2.13 Structs, literals and anonymous structs fields, literals, zero values, comparison, anonymous structs and a struct as a map value Open 2.14 Methods, value and pointer receivers methods, value against pointer receivers, the method set, method values and a counter that keeps its state Open

Lessons