Skip to content
Myr

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 file

Take it

fix: lint issues (#909)Carlos Alexandro Beckerbefore adoption817c4bd

line 1why, one step back
1// Package timeout handles context timeouts.

feat: handle interrupts and timeouts (#747)Carlos Alexandro Beckerbefore adoption4f46952

lines 2–16why, one step back
2package timeout
34import (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}