Compare commits

...

2 commits

Author SHA1 Message Date
WJQSERVER
ef965f4a6a
Merge pull request #75 from infinite-iroha/break/v1-fix-mergectx
Some checks are pending
Go Test / test (push) Waiting to run
fix: mergedContext.Value 遍历父 contexts 查找值
2026-03-30 16:45:09 +08:00
wjqserver
d90d043811 fix: mergedContext.Value 遍历父 contexts 查找值 2026-03-30 02:21:11 +08:00

View file

@ -75,7 +75,12 @@ func MergeCtx(parents ...context.Context) (ctx context.Context, cancel context.C
// Value 返回当前Ctx Value // Value 返回当前Ctx Value
func (mc *mergedContext) Value(key any) any { func (mc *mergedContext) Value(key any) any {
return mc.Context.Value(key) for _, p := range mc.parents {
if val := p.Value(key); val != nil {
return val
}
}
return nil
} }
// Deadline 实现了 context.Context 的 Deadline 方法. // Deadline 实现了 context.Context 的 Deadline 方法.