From 752ff3e43f3917ad60ed1af10f9f551ae68632e5 Mon Sep 17 00:00:00 2001 From: L1nSn0w Date: Fri, 5 Sep 2025 11:30:04 +0800 Subject: [PATCH] Fix missing return statement in GetRequestID function --- ...34\211\344\273\200\344\271\210\344\275\234\347\224\250.md" | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 函数在接收到取消信号后,直接退出,系统回收资源。