diff --git a/asyncLocal/context.go b/asyncLocal/context.go index e4abe74d4..b00302fec 100644 --- a/asyncLocal/context.go +++ b/asyncLocal/context.go @@ -34,9 +34,10 @@ func GetOrSetContext[T any](key string, getValFunc func() T) T { return val.(T) } - mVal[key] = getValFunc() + t = getValFunc() + mVal[key] = t routineContext.Set(mVal) - return mVal[key] + return t } // SetContext 写入上下文