From: Russ Cox Date: Thu, 27 Oct 2011 19:22:45 +0000 (-0700) Subject: spec: define that initialization is sequential X-Git-Tag: weekly.2011-11-01~46 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=b7ef3c9a5465762a19cec6bc925ddeda1a6b441a;p=gostls13.git spec: define that initialization is sequential This is true of the existing implementations, and I think it is an important property to guarantee. R=golang-dev, r, borman, r CC=golang-dev https://golang.org/cl/5321058 --- diff --git a/doc/go_spec.html b/doc/go_spec.html index fed7ed0348..34d8c81397 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -5149,12 +5149,22 @@ func main() { … }

Program execution begins by initializing the main package and then invoking the function main. -

-

When the function main returns, the program exits. It does not wait for other (non-main) goroutines to complete.

+

+Package initialization—variable initialization and the invocation of +init functions—happens in a single goroutine, +sequentially, one package at a time. +An init function may launch other goroutines, which can run +concurrently with the initialization code. However, initialization +always sequences +the init functions: it will not start the next +init until +the previous one has returned. +

+

Run-time panics