summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2014-05-20 17:46:08 -0700
committerRobert Griesemer <gri@golang.org>2014-05-20 17:46:08 -0700
commitff48d482e1fe5db3df5493b2589dcc63ab3717d6 (patch)
treeb3eb0d059341b84ad584e23c50d1d2f81e25be03
parent03f7f50d2b4c00a5f19e3b4f3a8624fa09ca9bfc (diff)
downloadgo1.3beta2.tar.gz
spec: specify order of init() callsgo1.3beta2
The spec did not specify the order in which init() functions are called. Specify that they are called in source order since we have now also specified the initialization order of independent variables. While technically a language change, no existing code could have relied on this, so this should not break anything. Per suggestion from rsc. LGTM=r, iant R=rsc, iant, r, ken CC=golang-codereviews https://codereview.appspot.com/98420046
-rw-r--r--doc/go_spec.html3
1 files changed, 2 insertions, 1 deletions
diff --git a/doc/go_spec.html b/doc/go_spec.html
index 01770395f..4c80f39d4 100644
--- a/doc/go_spec.html
+++ b/doc/go_spec.html
@@ -6008,7 +6008,8 @@ in a program.
<p>
A package with no imports is initialized by assigning initial values
to all its package-level variables followed by calling all <code>init</code>
-functions in unspecified order.
+functions in the order they appear in the source, possibly in multiple files,
+as presented to the compiler.
If a package has imports, the imported packages are initialized
before initializing the package itself. If multiple packages import
a package, the imported package will be initialized only once.