mirror of
https://github.com/golang/go
synced 2024-11-11 23:10:23 -07:00
- added language with respect to init() restrictions
R=r DELTA=10 (9 added, 0 deleted, 1 changed) OCL=16016 CL=16016
This commit is contained in:
parent
43c5e63c00
commit
566e3b2043
@ -2499,6 +2499,15 @@ functions defined in its source. Since a package may contain more
|
||||
than one source file, there may be more than one init() function, but
|
||||
only one per source file.
|
||||
|
||||
Initialization code may contain "go" statements, but the functions
|
||||
they invoke do not begin execution until initialization is complete.
|
||||
Therefore, all initialization code is run in a single thread of
|
||||
execution.
|
||||
|
||||
Furthermore, an "init()" function cannot be referred to from anywhere
|
||||
in a program. In particular, "init()" cannot be called explicitly, nor
|
||||
can a pointer to "init" be assigned to a function variable).
|
||||
|
||||
If a package has imports, the imported packages are initialized
|
||||
before initializing the package itself. If multiple packages import
|
||||
a package P, P will be initialized only once.
|
||||
|
Loading…
Reference in New Issue
Block a user