From a88f7e476b4695f1c45a91a690b54bcd39ac91b8 Mon Sep 17 00:00:00 2001 From: Sunil Joshi <4852488+c0dehu1k@users.noreply.github.com> Date: Fri, 6 Oct 2023 15:44:19 +0530 Subject: [PATCH 1/4] context withoutCancel --- docs/index.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/index.md b/docs/index.md index c7c2910..c159aed 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1439,6 +1439,9 @@ When the response has been written to the client, the context associated with th In the latter case, calling publish will return an error because we returned the HTTP response quickly. +Note: From Go 1.21, there is a way to create a new context without cancel. WithoutCancel returns a copy of parent that is not canceled when parent is canceled. +Read more [here](https://pkg.go.dev/context#WithoutCancel) + In summary, propagating a context should be done cautiously. [Source code :simple-github:](https://github.com/teivah/100-go-mistakes/tree/master/src/09-concurrency-practice/61-inappropriate-context/main.go) From c8325f0511ffefba315fc2ecbb8cf3322abde3ed Mon Sep 17 00:00:00 2001 From: Sunil Joshi <4852488+c0dehu1k@users.noreply.github.com> Date: Mon, 9 Oct 2023 17:31:31 +0530 Subject: [PATCH 2/4] Incorporating review comments --- docs/index.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/index.md b/docs/index.md index c159aed..61644fa 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1439,8 +1439,9 @@ When the response has been written to the client, the context associated with th In the latter case, calling publish will return an error because we returned the HTTP response quickly. -Note: From Go 1.21, there is a way to create a new context without cancel. WithoutCancel returns a copy of parent that is not canceled when parent is canceled. -Read more [here](https://pkg.go.dev/context#WithoutCancel) +???+ note + + From Go 1.21, there is a way to create a new context without cancel. [`context.WithoutCancel`](https://pkg.go.dev/context#WithoutCancel) returns a copy of parent that is not canceled when parent is canceled. In summary, propagating a context should be done cautiously. From 239165afcfe25c028e7d9e16969c423aa3323c19 Mon Sep 17 00:00:00 2001 From: Sunil Joshi <4852488+c0dehu1k@users.noreply.github.com> Date: Mon, 9 Oct 2023 17:33:45 +0530 Subject: [PATCH 3/4] Incorporating review comments --- docs/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/index.md b/docs/index.md index 61644fa..7ea77d0 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1439,7 +1439,7 @@ When the response has been written to the client, the context associated with th In the latter case, calling publish will return an error because we returned the HTTP response quickly. -???+ note +???+note From Go 1.21, there is a way to create a new context without cancel. [`context.WithoutCancel`](https://pkg.go.dev/context#WithoutCancel) returns a copy of parent that is not canceled when parent is canceled. From 290a7864e98dcfbfc7c915a71809f95533857e18 Mon Sep 17 00:00:00 2001 From: Sunil Joshi <4852488+c0dehu1k@users.noreply.github.com> Date: Mon, 9 Oct 2023 17:35:39 +0530 Subject: [PATCH 4/4] Incorporating review comments --- docs/index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/index.md b/docs/index.md index 7ea77d0..ea5f033 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1439,9 +1439,9 @@ When the response has been written to the client, the context associated with th In the latter case, calling publish will return an error because we returned the HTTP response quickly. -???+note +???+ note - From Go 1.21, there is a way to create a new context without cancel. [`context.WithoutCancel`](https://pkg.go.dev/context#WithoutCancel) returns a copy of parent that is not canceled when parent is canceled. + From Go 1.21, there is a way to create a new context without cancel. [`context.WithoutCancel`](https://pkg.go.dev/context#WithoutCancel) returns a copy of parent that is not canceled when parent is canceled. In summary, propagating a context should be done cautiously.