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 things if there was no error above and finally
    w.Write(someBytes)
}

My question is: Assuming there is no point carrying on after "Something bad
happened" why don't we just return (after writing someBytes to w inside the if
error != nil if that is what is expected). I have never seen any code that
returns after calling Error(), and I wonder why.


Thanks for the help.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAA_NO6gX4cZWmqdGGLheC1ydZrcrC2TpzDkf_JN7dmY0WGEXew%40mail.gmail.com.

Reply via email to