From 8cb9184d7ff869ad4ddd3174cb301bc88db15178 Mon Sep 17 00:00:00 2001
From: Rob Pike T
:
A field declaration may be followed by an optional string literal tag,
which becomes an attribute for all the identifiers in the corresponding
field declaration. The tags are made
-visible through a reflection library TODO: reference?
+visible through a reflection interface
but are otherwise ignored.
...
parameter are wrapped into a struct
that is passed to the function instead of the actual arguments.
-Using the reflection library (TODO: reference), f
may
+Using the reflection interface, f
may
unpack the elements of the dynamic type to recover the actual
arguments.
@@ -4281,8 +4281,7 @@ var t T
A package with no imports is initialized by assigning initial values to -all its package-level variables in data-dependency order -(TODO: clarify) +all its package-level variables and then calling any package-level function with the name and signature of
@@ -4296,6 +4295,25 @@ than one source file, there may be more than one only one per source file.
+Within a package, package-level variables are initialized,
+and constant values are determined, in
+data-dependent order: if the initializer of A
+depends on the value of B
, A
+will be set after B
.
+It is an error if such dependencies form a cycle.
+Dependency analysis is done lexically: A
+depends on B
if the value of A
+contains a mention of B
, contains a value
+whose initializer
+mentions B
, or mentions a function that
+mentions B
, recursively.
+If two items are not interdependent, they will be initialized
+in the order they appear in the source.
+Since the dependency analysis is done per package, it can be
+defeated if A
's initializer calls a function defined
+in another package that refers to B
.
+
Initialization code may contain "go" statements, but the functions they invoke do not begin execution until initialization of the entire program is complete. Therefore, all initialization code is run in a single