v0.0.0-...-15a9a0c Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: May 19, 2023 License: BSD-3-Clause Imports: 3 Imported by: 0



Package ctxutil provides convenience functions for working with context.Context objects.



View Source
const MaxTimeout time.Duration = math.MaxInt64

MaxTimeout is the maximum value of time.Duration, approximately 290 years.

This value might be useful on calling some timeout-related functions. For example, context.WithTimeout(ctx, ctxutil.MaxTimeout) returns a new context with effectively the same deadline as the original context. (Precisely, if the original context has no deadline or a deadline later than MaxDuration, the new deadline is different, but it is so future that we do not need to distinguish them.)


This section is empty.


func DeadlineBefore

func DeadlineBefore(ctx context.Context, t time.Time) bool

DeadlineBefore returns true if ctx has a deadline that expires before t. It returns true if the deadline has already expired and false if no deadline is set.

func Shorten

Shorten returns a context and cancel function derived from ctx with its deadline shortened by d. If ctx has no deadline, the returned context won't have one either. Note that if ctx's deadline is less than d in the future, the returned context's deadline will have already expired.


This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL