-
Notifications
You must be signed in to change notification settings - Fork 0
0917main函数作用域与非main函数作用域的区别
ziyouzy edited this page Sep 18, 2020
·
1 revision
func f3_0(){
s :="test"
func (){
time.Sleep(time.Duration(3)*time.Second)
s ="test3"
fmt.Println("outside s:", s)
}()
s ="test2"
}
func f3_1(){
s :="test"
go func (){
time.Sleep(time.Duration(3)*time.Second)
s ="test3"
fmt.Println("outside s:", s)
}()
s ="test2"
}
func f3_2(){
s :="test"
for i:=0;i<10;i++{
time.Sleep(time.Duration(3)*time.Second)
s ="test3"
fmt.Println("outside s:", s)
}
s ="test2"
}
func f3(){
s :="test"
go func (){
time.Sleep(time.Duration(3)*time.Second)
//s ="test3"
fmt.Println("outside s:", s)
}()
fmt.Println("f3() done")
}