Go under the hood
Go: Under the Hood

Chapter 3 The Life of a Program

An adequate bootstrap is a contradiction in terms.
-- Alan J. Perlis, "Epigrams on Programming"

The main function the reader types is never where the program truly begins. For a line of source to become a running process, it first has to pass through a long chain: the go command breaks the build into an action graph and hands it to the compiler and linker, the compiler itself must be bootstrapped from a previous version of Go, the linker stitches the entire runtime into the binary, and once the operating system loads it, an assembly entry point lays down the first goroutine, only then does main.main get its turn to run, and at the moment it returns it carries the whole process away with it. This chapter walks down that lifeline from start to finish, explaining exactly what happens before and after main without leaving anything out. It is both the master entry point to the later parts of the book (runtime, concurrency, memory, toolchain) and the starting point for understanding Go’s fundamental trait that the runtime and user code share a single binary.