Skip to content

Commit 65cb367

Browse files
authored
Fix missing return statement in GetRequestID function (#77)
1 parent 1d12236 commit 65cb367

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

content/stdlib/context/2-context 有什么作用.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ func WithRequestID(next http.Handler) http.Handler {
123123

124124
// 获取 request-id
125125
func GetRequestID(ctx context.Context) string {
126-
ctx.Value(requestIDKey).(string)
126+
return ctx.Value(requestIDKey).(string)
127127
}
128128

129129
func Handle(rw http.ResponseWriter, req *http.Request) {
@@ -257,4 +257,4 @@ func main() {
257257
}
258258
```
259259

260-
增加一个 context,在 break 前调用 cancel 函数,取消 goroutine。gen 函数在接收到取消信号后,直接退出,系统回收资源。
260+
增加一个 context,在 break 前调用 cancel 函数,取消 goroutine。gen 函数在接收到取消信号后,直接退出,系统回收资源。

0 commit comments

Comments
 (0)