一、Context 详解
1.1 Context 概述
context.Context 是 Go 并发编程的核心工具,用于传递取消信号、超时控制和请求级数据。
Context 层级关系
Background(根 Context)
├── WithCancel → 手动取消
├── WithDeadline → 截止时间
├── WithTimeout → 超时时间
└── WithValue → 传递数据
├── 子 Context 1
│ └── 子 Context 1.1
└── 子 Context 2
2026/3/20大约 8 分钟