diff options
author | Russ Cox <rsc@golang.org> | 2011-10-27 12:22:45 -0700 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2011-10-27 12:22:45 -0700 |
commit | b7ef3c9a5465762a19cec6bc925ddeda1a6b441a (patch) | |
tree | 9429fc696b4780ef54abed76f5213bc7b091dda2 | |
parent | fd31d9fd7beaac218899c5bdb74004152b076d82 (diff) | |
download | go-b7ef3c9a5465762a19cec6bc925ddeda1a6b441a.tar.gz go-b7ef3c9a5465762a19cec6bc925ddeda1a6b441a.zip |
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
-rw-r--r-- | doc/go_spec.html | 14 |
1 files changed, 12 insertions, 2 deletions
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() { … } <p> Program execution begins by initializing the main package and then invoking the function <code>main</code>. -</p> -<p> When the function <code>main</code> returns, the program exits. It does not wait for other (non-<code>main</code>) goroutines to complete. </p> +<p> +Package initialization—variable initialization and the invocation of +<code>init</code> functions—happens in a single goroutine, +sequentially, one package at a time. +An <code>init</code> function may launch other goroutines, which can run +concurrently with the initialization code. However, initialization +always sequences +the <code>init</code> functions: it will not start the next +<code>init</code> until +the previous one has returned. +</p> + <h2 id="Run_time_panics">Run-time panics</h2> <p> |