This is a creation in Article, where the information may have evolved or changed.
The Go language function is passed as a parameter, and now I feel almost the same as C + +. It's very flexible.
Import"FMT"Import" Time"func goFunc1 (f func ()) {go f ()}func GoFunc2 (f func (Interface{}), IInterface{}) {go f (i)}func Gofunc (fInterface{}, args ...Interface{}) { ifLen (args) >1{go f. (Func ( ...Interface{})) (args)}Else ifLen (args) = =1{go f. (Func (Interface{})) (args[0]) } Else{go f. (func ())} ()}}func F1 () {FMT. Println ("F1 Done")}func F2 (iInterface{}) {Fmt. Println ("F2 Done", I)} Func f3 (Args ...Interface{}) {Fmt. Println ("F3 Done", args)} Func Main () {goFunc1 (F1) GoFunc2 (F2, -) Gofunc (F1) Gofunc (F2,"xxxx") Gofunc (F3,"Hello"," World",1,3.14) time. Sleep (5*Time . Second)}
F1 done
F2 done 100
F1 done
F2 done xxxx
F3 done [[Hello World 1 3.14]]
Transfer from http://blog.csdn.net/eclipser1987/article/details/11772539