We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1d12236 commit 65cb367Copy full SHA for 65cb367
content/stdlib/context/2-context 有什么作用.md
@@ -123,7 +123,7 @@ func WithRequestID(next http.Handler) http.Handler {
123
124
// 获取 request-id
125
func GetRequestID(ctx context.Context) string {
126
- ctx.Value(requestIDKey).(string)
+ return ctx.Value(requestIDKey).(string)
127
}
128
129
func Handle(rw http.ResponseWriter, req *http.Request) {
@@ -257,4 +257,4 @@ func main() {
257
258
```
259
260
-增加一个 context,在 break 前调用 cancel 函数,取消 goroutine。gen 函数在接收到取消信号后,直接退出,系统回收资源。
+增加一个 context,在 break 前调用 cancel 函数,取消 goroutine。gen 函数在接收到取消信号后,直接退出,系统回收资源。
0 commit comments