# README
goid
goid包是go版的ThreadLocal,用于在多个协程之间传递数据
// 变量分配
var TestIdLocal = goid.NewLocalStorage()
// 设置
TestIdLocal.Set(tenantId)
// 获取
TestIdLocal.Get()
注意:
在遇到协程的时候,请不要使用go的原生方式,请使用如下的方式,否则goid数据无法传递
// 启用协程
goid.Go(func() {
// ...
})
# Functions
AllGoids return all goroutine's goid in the current golang process.
BackupContext copy all local storages into an ImmutableContext instance.
No description provided by the author
No description provided by the author
Go start an new goroutine, and copy all local storages from current goroutine.
Goid return the current goroutine's unique id.
InheritContext load the specified ImmutableContext instance into the local storage of current goroutine.
No description provided by the author
NewLocalStorage create and return an new LocalStorage instance.
# Structs
ImmutableContext represents all local storages of one goroutine.
# Interfaces
LocalStorage provides goroutine-local variables.