1 Star 0 Fork 0

xlizy/common-go

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
threadlocal.go 497 Bytes
一键复制 编辑 原始数据 按行查看 历史
xlizy 提交于 2024-04-09 16:42 . init
package threadlocal
import "github.com/timandy/routine"
var traceID = routine.NewInheritableThreadLocal[string]()
var userID = routine.NewInheritableThreadLocal[string]()
func SetTraceId(traceId string) {
traceID.Set(traceId)
}
func GetTraceId() string {
if traceID.Get() != "" {
return traceID.Get()
} else {
return "<nil>"
}
}
func SetUserId(userId string) {
userID.Set(userId)
}
func GetUserId() string {
if userID.Get() != "" {
return userID.Get()
} else {
return ""
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/xlizy/common-go.git
git@gitee.com:xlizy/common-go.git
xlizy
common-go
common-go
v0.1.5

搜索帮助

23e8dbc6 1850385 7e0993f3 1850385