If statement
Continue to see the main function of the Docker.go file
if reexec. Init () { return }
If the go language does not need to be bracketed like any other language, and you can add an assignment statement before judging
Grammar
" if " " ; " " Else " (ifstmt | Block)].
Example
if x: = f (); x < y { returnElseif x > z { return Else { return y}
Map structure
Continue to follow the reexec. Init () method inside, file located in Docker/reexec/reexec.go
varRegisteredinitializers = Make (map[string]func ()) ...//Init is called as the first part of the exec process and returns true if an//initialization function was called.Func Init ()BOOL{initializer, exists:= Registeredinitializers[os. args[0]] ifexists {initializer ()return true } return false}
You can see that registeredinitializers is a map type with a key type of string and a value type of func ().
The initialization of map is done by make (), which is the built-in method of go.
In addition to making, you can initialize it by using a method similar to the following
mapcreated: = map[stringint { 1int {return }, 2int {return), 3 int {return,}, }
Continue to see the use of maps through code
initializer, exists: = Registeredinitializers[os. args[0]]
Map[keyvalue] Returns two values, first to see the second one, to indicate whether there is a value, the first is to get the values in the case of existence, and here is to get this func ().
The next code is to determine if there is a func () to execute if it exists.
If we do not want to take value, we just want to know if it exists, we can omit the return by adding an underscore _, for example
_, exists: = XXX