move go files to src/

This commit is contained in:
2025-10-10 22:46:24 +03:00
parent f0c591f325
commit 57f35e8f33
45 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
package utils
import (
"log"
"runtime"
"golang.org/x/net/context"
)
func CatchPanic() {
if err := recover(); err != nil {
stack := make([]byte, 8096)
stack = stack[:runtime.Stack(stack, false)]
log.Printf("recovered panic:\n%s", stack)
}
}
func CatchPanicWithCancel(cancel context.CancelFunc) {
if err := recover(); err != nil {
stack := make([]byte, 8096)
stack = stack[:runtime.Stack(stack, false)]
log.Printf("recovered panic:\n%s", stack)
cancel()
}
}
func CatchPanicWithFallback(onPanic func(any)) {
if err := recover(); err != nil {
stack := make([]byte, 8096)
stack = stack[:runtime.Stack(stack, false)]
log.Printf("recovered panic:\n%s", stack)
onPanic(err)
}
}