I tried to write the SSA information out and found the *init$guard *which
is likely to decide the execution of the sub-packages *init *functions.
For example, give the following go code, I will get the SSA output.
package main
import "fmt"
import _ "unsafe"
const message = "Hello, World!"
func init(){}
func main() {
fmt.Println(message)
}
func empty(){}
The output is shown below. Based on the code, I have a rough idea that the
variable *init$guard *might be set by someone to control the execution of
*init*. However, i failed to find the documentation about it when I search
"init$guard", "package initializer" and so on. Could someone help to
explain how it works and which component sets up the variable.
*# Name: hello.init# Package: hello# Synthetic: package initializerfunc
init():0:
entry P:0 S:2 t0 = *init$guard
bool if t0 goto 2 else 11:
init.start P:1 S:1 *init$guard =
true:bool t1 = fmt.init()
() t2 = unsafe.init()
() t3 = init#1()
() jump 22:
init.done P:2 S:0 return*
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/golang-nuts/b851ef80-838c-4bbb-b575-508ae1988f39n%40googlegroups.com.