topics/go/packages/context/README.md
The package context defines the Context type, which carries deadlines, cancellation signals, and other request-scoped values across API boundaries and between processes.
Context Package Semantics In Go - William Kennedy
Package context - Go Team
Go Concurrency Patterns: Context - Sameer Ajmani
Cancellation, Context, and Plumbing - Sameer Ajmani
Using contexts to avoid leaking goroutines - JBD
"Context values are for request-scoped data that passes through programs in a distributed system. Litmus test: Could it be an HTTP header?" - Sameer Ajmani
Store / Retrieve context values (Go Playground)
WithCancel (Go Playground)
WithDeadline (Go Playground)
WithTimeout (Go Playground)
Request/Response (Go Playground
Cancellation (Go Playground
Use the template and follow the directions. You will be writing a web handler that performs a mock database call but will timeout based on a context if the call takes too long. You will also save state into the context.
Template (Go Playground) | Answer (Go Playground)
All material is licensed under the Apache License Version 2.0, January 2004.