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:

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

2023-07-04 Thread ben...@gmail.com
> Every example of http Handler that I have seen so far looks like this: Yes, that's definitely odd. I just grepped my Go source directory (which includes the Go compiler and stdlib and a bunch of other Go code), and almost all of them have a "return" on the next line. For example: $ rg

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

2023-07-04 Thread Jan Mercl
On Tue, Jul 4, 2023 at 5:38 PM Gurunandan Bhat wrote: > 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,

[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