mirror of
https://github.com/duanhf2012/origin.git
synced 2026-02-14 15:54:42 +08:00
优化代码规范
This commit is contained in:
@@ -7,18 +7,18 @@ import (
|
||||
"runtime/debug"
|
||||
)
|
||||
|
||||
func F(callback interface{},recoverNum int, args ...interface{}) {
|
||||
func F(callback interface{}, recoverNum int, args ...interface{}) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
var coreInfo string
|
||||
coreInfo = string(debug.Stack())
|
||||
coreInfo += "\n" + fmt.Sprintf("Core information is %v\n", r)
|
||||
log.SError(coreInfo)
|
||||
if recoverNum > 0{
|
||||
if recoverNum > 0 {
|
||||
recoverNum -= 1
|
||||
}
|
||||
if recoverNum == -1 || recoverNum > 0 {
|
||||
go F(callback,recoverNum, args...)
|
||||
go F(callback, recoverNum, args...)
|
||||
}
|
||||
}
|
||||
}()
|
||||
@@ -36,10 +36,10 @@ func F(callback interface{},recoverNum int, args ...interface{}) {
|
||||
}
|
||||
|
||||
func Go(callback interface{}, args ...interface{}) {
|
||||
go F(callback,0, args...)
|
||||
go F(callback, 0, args...)
|
||||
}
|
||||
|
||||
//-1表示一直恢复
|
||||
func GoRecover(callback interface{},recoverNum int, args ...interface{}) {
|
||||
go F(callback,recoverNum, args...)
|
||||
}
|
||||
// GoRecover -1表示一直恢复
|
||||
func GoRecover(callback interface{}, recoverNum int, args ...interface{}) {
|
||||
go F(callback, recoverNum, args...)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user