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

9 lines
302 B
Go

- 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()