diff --git a/src/HttpServer/logic/httpserver.go b/src/HttpServer/logic/httpserver.go index 7e99418..ba0d5e6 100644 --- a/src/HttpServer/logic/httpserver.go +++ b/src/HttpServer/logic/httpserver.go @@ -90,6 +90,21 @@ func QueryAllAccount(w http.ResponseWriter, r *http.Request) { logger.Info("QueryAllAccount ") + + defer func() { + //recover() //可以打印panic的错误信息 + //fmt.Println(recover()) + if err := recover(); err != nil { //产生了panic异常 + fmt.Println(err) + } + + }() //别忘了(), 调用此匿名函数 + type A struct { + a int + } + var a *A + a.a = 1 + //先打开文件 filename := "./data.txt" var f *os.File diff --git a/src/HttpServer/main/main.go b/src/HttpServer/main/main.go index 1777c83..6813739 100644 --- a/src/HttpServer/main/main.go +++ b/src/HttpServer/main/main.go @@ -2,7 +2,6 @@ package main import ( "HttpServer/conf" - "fmt" "mysql" "HttpServer/logic" @@ -70,20 +69,6 @@ func main() { //time.Sleep(time.Duration(2) * time.Second) //logic.Testsendhttp() - defer func() { - //recover() //可以打印panic的错误信息 - //fmt.Println(recover()) - if err := recover(); err != nil { //产生了panic异常 - fmt.Println(err) - } - - }() //别忘了(), 调用此匿名函数 - type A struct { - a int - } - var a *A - a.a = 1 - select { case _ = <-ch: -- libgit2 0.21.0