7
golang 中在init之前运行的函数
source link: https://zhangyiming748.github.io/post/golang_before_init/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
golang 中在init之前运行的函数
2023-11-23 Golang
package main
import "fmt"
var a = 8
// b 会最先运行
var b = func() int {
fmt.Println("b")
return 0
}()
func init() {
fmt.Println("init")
}
func main() {
fmt.Println("main")
}
func hello() {
fmt.Println("hello")
}
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK