[go-nuts] Re: How do library functions that accept a context implement context cancellation inside?

2023-07-21 Thread Gurunandan Bhat
Sorry - I meant ..."calling select once per line" be a good point On Fri, Jul 21, 2023 at 12:41 PM Gurunandan Bhat wrote: > Hi, > > Are there any common patterns that standard and 3rd party library > functions use to implement cancelling a context passed to it? I have

[go-nuts] How do library functions that accept a context implement context cancellation inside?

2023-07-21 Thread Gurunandan Bhat
Hi, Are there any common patterns that standard and 3rd party library functions use to implement cancelling a context passed to it? I have looked at the source of exec.CommandContext and it starts the process and spawns a goroutine that kills the process when ctx.Done() is closed. That looks

Re: [go-nuts] Why not return after calling http.Error()

2023-07-06 Thread Gurunandan Bhat
Thanks to everyone who reassured me. I considered posting a set of links from the most popular Golang tutorials that do not return after calling http.Error(), but then baulked In any case, thanks once again to all in this thread. Regards On Wed, Jul 5, 2023 at 4:13 AM ben...@gmail.com wrote:

[go-nuts] Why not return after calling http.Error()

2023-07-04 Thread Gurunandan Bhat
Every example of http Handler that I have seen so far looks like this: func handleSomeRequest(w http.ResponseWriter, r *http.Request) { // do something that returns an error if err != nil { http.Error(w, "Something bad happened", http.SomeAppropriateStatus) } // do other