feat: update template

This commit is contained in:
2026-08-19 22:05:49 +08:00
parent 0e674e9d56
commit 5a71093b0c
67 changed files with 2070 additions and 585 deletions

View File

@@ -0,0 +1,18 @@
package safego
import (
"log/slog"
"runtime/debug"
)
// Go 以协程执行 fn并捕获 panic 记录日志,防止协程崩溃杀死整个进程
func Go(fn func()) {
go func() {
defer func() {
if r := recover(); r != nil {
slog.Error("goroutine panic recovered", "panic", r, "stack", string(debug.Stack()))
}
}()
fn()
}()
}