go-concurrency-talk/figures/figure-6.go

9 lines
302 B
Go
Raw Normal View History

2020-06-05 19:39:30 +00:00
- hctx, hcancel := context.WithCancel(ctx) // HL
+ var hctx context.Context // HL
+ var hcancel context.CancelFunc // HL
if c.headerTimeout > 0 {
hctx, hcancel = context.WithTimeout(ctx, c.headerTimeout)
+ } else { // HL
+ hctx, hcancel = context.WithCancel(ctx) // HL
}
defer hcancel()