优化代码规范

This commit is contained in:
duanhf2012
2024-09-20 17:25:08 +08:00
parent 1cf071a444
commit 39116c4402
63 changed files with 1971 additions and 2043 deletions

View File

@@ -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...)
}