在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
使用log模块示例代码: package main import ( "fmt" "time" "log" "os" ) func main() { go func() { defer func() { i := recover() if i != nil { file, _ := os.Create("error.log") defer file.Close() logger := log.New(file, "[Error] ", log.Ldate|log.Ltime) // [Error] 2018/07/28 17:43:23 runtime error: invalid memory address or nil pointer dereference logger.Println(i) } }() var p *int //p = new(int) *p = 1000 fmt.Println("hello") }() time.Sleep(time.Second) fmt.Println("hello main") }
|
请发表评论