一个入门的goroutines例子
package main
import (
"fmt"
"time"
)
func f(from string) {
for i := 0; i < 3; i++ {
fmt.Println(from, ":", i)
}
}
func main() {
f("direct")
go f("goroutine")
go func(msg string) {
fmt.Println(msg)
}("going")
time.Sleep(time.Second)
fmt.Println("done")
}
标签:fmt,go,func,time,Println,example,Goroutines
From: https://www.cnblogs.com/bovyfly/p/17368857.html