前端之家收集整理的这篇文章主要介绍了
Timer的使用 引用(指针)的测试,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
<!-- lang: cpp -->
package main
import (
"fmt"
"time"
)
func panic_test(){
defer func() {
fmt.Println("no")
// if e := recover(); e != nil {
// fmt.Println("some wrong:",e)
// }
}()
z := 0
zero := 1/z
fmt.Println(zero)
}
func main() {
panic_test()
go func() {
for a := range time.Tick(1e9) {
fmt.Printf("cur conn num: %v\n",a)
}
}()
list := []string{"a","b","c","d"}
//fmt.Printf("in main,list addr is %p \r\n",list)
go func( list []string) {
//fmt.Printf("in goruotine,list)
time.Sleep(1e9)
(list)[2] = "CC"
list = append(list,"FF")
for i,c := range list{
fmt.Println( "in go",i,c)
}
}(list)
for i,c := range list{
fmt.Println( i,c)
time.Sleep(1e9)
}
fmt.Println( "second printf")
for i,c)
//time.Sleep(1e9)
}
for{time.Sleep(1e5)}
}
原文链接:https://www.f2er.com/go/190937.html