package
Version:
v1.89.0
Opens a new window with list of versions in this module.
Published: Aug 24, 2026
License: MIT
Opens a new window with license information.
Imports: 3
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
Documentation
¶
Package safe 提供 goroutine panic 治理工具:
业务/回调在独立 goroutine 中 panic 时,默认行为是崩溃整个进程;
safe.Go 捕获 panic 并记录日志与堆栈,保证服务继续运行。
func Go(name string, fn func())
Go 启动带 panic 恢复的 goroutine:fn 内部 panic 会被捕获,
记录组件名、错误与堆栈后继续运行(不崩溃进程)。
用法:
safe.Go("redqueue consume", func() { ... })
Recover 供 defer 使用:捕获当前 goroutine 的 panic 并记录日志。
defer safe.Recover("my goroutine")
Source Files
¶
Click to show internal directories.
Click to hide internal directories.