2020
12-18
12-18
go语言的初始化顺序,包,变量,init详解
依次见例子代码:p1.gopackagep1import"fmt"//1.1varxfloat32=1.2//1.2funcinit(){//1.3fmt.Printf("p1package,x:%f\n",x)//1.4}funcDonothing(){fmt.Println("donothing.\n")}a.go:packagemainimport"fmt"varWhatIsThe1=AnswerToLife(2.1)//2.1varWhatIsThe2=AnswerToLife(2.2)//2.2varWhatIsThe3=AnswerToLife(2.3)//2.3funcinit(){//3.1fmt.Printf("initWhatIsTheina.go`sinit3...
继续阅读 >