Context Package: Cancellation, Timeouts & Deadlines | Go Tutorial #28
27views
0011:56
T
Taught by Celeste AI - AI Coding Coach
View on YouTubeDescription
Learn the context package in Go! Context is essential for managing cancellation, timeouts, and request-scoped data in concurrent and
networked programs.
📚 What you'll learn:
- context.Background() and context.TODO() - the root contexts
- context.WithCancel() - manual cancellation and propagation
- context.WithTimeout() and WithDeadline() - automatic cancellation
- context.WithValue() - passing request-scoped data safely
- Best practices for passing context through your code
Context is one of the most important packages in Go - used everywhere from HTTP servers to database queries to gRPC calls.
⏱️ Timestamps:
0:00 - Introduction
0:30 - Context Basics (Background, TODO, passing context)
2:49 - WithCancel (cancellation propagation)
5:04 - WithTimeout & WithDeadline (automatic cancellation)
7:47 - WithValue (request-scoped data, typed keys)
10:45 - Recap
11:15 - Up Next: Unit Testing
💻 Code: https://github.com/GoCelesteAI/go_context
🔔 Subscribe for more Go tutorials!
Back to tutorialsOpen in YouTube
Duration
11:56
Published
February 5, 2026
Added to Codegiz
March 15, 2026