Skip to content
masterclass Buddy

Go · Interface

context.Context

Use context.Context to carry cancellation and deadlines through Go calls. Create a derived context with a timeout, pass it to the operation, and always call the returned cancel function.

Last updated

Syntax

func WithTimeout(parent Context, timeout time.Duration) (Context, CancelFunc)

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • Context
  • WithCancel
  • WithCancelCause
  • WithDeadline
  • WithTimeoutCause
  • Done
  • Err
  • Cause

Source: Canceling in-progress operations - The Go Programming Language. Checked 2026-11-03.