diff --git "a/content/stdlib/context/2-context \346\234\211\344\273\200\344\271\210\344\275\234\347\224\250.md" "b/content/stdlib/context/2-context \346\234\211\344\273\200\344\271\210\344\275\234\347\224\250.md" index 4073794..0ea8ddd 100644 --- "a/content/stdlib/context/2-context \346\234\211\344\273\200\344\271\210\344\275\234\347\224\250.md" +++ "b/content/stdlib/context/2-context \346\234\211\344\273\200\344\271\210\344\275\234\347\224\250.md" @@ -123,7 +123,7 @@ func WithRequestID(next http.Handler) http.Handler { // 获取 request-id func GetRequestID(ctx context.Context) string { - ctx.Value(requestIDKey).(string) + return ctx.Value(requestIDKey).(string) } func Handle(rw http.ResponseWriter, req *http.Request) { @@ -257,4 +257,4 @@ func main() { } ``` -增加一个 context,在 break 前调用 cancel 函数,取消 goroutine。gen 函数在接收到取消信号后,直接退出,系统回收资源。 \ No newline at end of file +增加一个 context,在 break 前调用 cancel 函数,取消 goroutine。gen 函数在接收到取消信号后,直接退出,系统回收资源。