Skip to content
masterclass Buddy

Go · Function

context.WithTimeout

context.WithTimeout creates a context that is canceled after a time limit. It returns the new context and a function that can cancel it earlier.

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
  • WithDeadline
  • WithCancel
  • DeadlineExceeded
  • Canceled

Source: context package - github.com/hashicorp/go.net/context - Go Packages. Checked 2026-11-03.