From f6183a0cac9fca092cfa842239c17c53b932eedc Mon Sep 17 00:00:00 2001 From: sado Date: Fri, 13 Oct 2023 18:14:52 +0800 Subject: [PATCH] add kit localcache --- pkg/syncx/syncx.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 pkg/syncx/syncx.go diff --git a/pkg/syncx/syncx.go b/pkg/syncx/syncx.go new file mode 100644 index 0000000..e9cd481 --- /dev/null +++ b/pkg/syncx/syncx.go @@ -0,0 +1,17 @@ +package syncx + +import ( + "fmt" + "log" + "runtime/debug" +) + +func GoSave(fn func()) { + defer func() { + if p := recover(); p != nil { + log.Printf("[ERROR]: %s", fmt.Sprintf("%s\n%s", p, string(debug.Stack()))) + } + }() + + fn() +}