Go Bootstrapping

Briefly describe the bootstrapping process of a go executable.

Answer

  1. Run the platform-specific assembly that is located under $GOROOT/src/runtime/
  2. runtime·args(): Parse terminal arguments
  3. runtime·osinit(): Initialize CPU cores
  4. runtime·schedinit(): Initialize goroutine scheduler, stack memory, terminal arguments, environment variables, debug parameter, gc, GOMAXPROCS, ...
  5. runtime·mstart(): Start gc monitor, enable gc, import dependencies and run init() functions, finally run main.main()