func foo(w http.ResponseWriter, r *http.Request, status int, data interface{}){
if err := encoder.Encode(w, r, data); err != nil {
http.Error(//error here)
}
}
foo(w, r, http.StatusBadRequest, fmt.Errorf("Invalid message")
this returns {} in an error condition instead of writing the actual error(Invalid message), what I am missing here. I want function to write the given error message.
What is encoder.Encode? It doesn’t appear to be in the standard library and it’s hard to know how to help fix the code without knowing what the function is doing.
A playground link would be marvelous too, although I realize it’s not always that easy to yank something out of a large code base and get it running there.