context.go
This file
Path
internal/timeout/context.go
16 lines · 363 bytes · Go
Last changed by
fix: lint issues (#909)Carlos Alexandro Beckerbefore adoption817c4bd
History of this fileTake it
1// Package timeout handles context timeouts.2package timeout34import (5 "context"6 "time"7)89// Context setup a new context that times out if the given timeout is > 0.10func Context(timeout time.Duration) (context.Context, context.CancelFunc) {11 ctx := context.Background()12 if timeout == 0 {13 return ctx, func() {}14 }15 return context.WithTimeout(ctx, timeout)16}