这是报错:
2016/06/16 07:20:29 http: panic serving 127.0.0.1:55356: sql: database is closed
goroutine 1789 [running]:
net/http.(*conn).serve.func1(0xc82157e200)
/usr/local/go/src/net/http/server.go:1389 +0xc1
main.checkErr(0x6b4028, 0xc82000aed0)
/data/go/src/basis/main.go:86 +0x4b
main.(*sqlOpen).mysqlSelect(0xc820028020, 0x1201078, 0xc820060680, 0xc821828540)
/data/go/src/basis/main.go:38 +0xdd
main.(*sqlOpen).(main.mysqlSelect)-fm(0x1201078, 0xc820060680, 0xc821828540)
/data/go/src/basis/main.go:93 +0x3e
net/http.HandlerFunc.ServeHTTP(0xc82000b000, 0x1201078, 0xc820060680, 0xc821828540)
/usr/local/go/src/net/http/server.go:1618 +0x3a
net/http.(*ServeMux).ServeHTTP(0xc820014ab0, 0x1201078, 0xc820060680, 0xc821828540)
/usr/local/go/src/net/http/server.go:1910 +0x17d
net/http.serverHandler.ServeHTTP(0xc820066080, 0x1201078, 0xc820060680, 0xc821828540)
/usr/local/go/src/net/http/server.go:2081 +0x19e
net/http.(*conn).serve(0xc82157e200)
/usr/local/go/src/net/http/server.go:1472 +0xf2e
created by net/http.(*Server).Serve
/usr/local/go/src/net/http/server.go:2137 +0x44e
这是我的链接数据库:
database , err := sql.Open( "mysql" , "admin:admin@tcp(192.168.200.101:3306)/test_database?charset=utf8" )
if err != nil {
checkErr( err )
}
s.db = database
return
本人刚开始学习不知道问题是什么,初步怀疑是因为连接数大照成的。不知道正确不正确,求牛人指点一二谢谢
有疑问加站长微信联系(非本文作者)