Go - init function

There is a init() function, as the name suggests, it will do some initialization work, such as initializing variables which may not be expressed easily, or calibrating program state. A file can contain one or more init() functions, as shown here: package main import "fmt" var global int = 0 func init() { global++ fmt.Println("In first Init(), global is: ", global) } func init() { global++ fmt.Println("In Second Init(), global is: ", global) } func main() { fmt. [Read More]