1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
package helpers import ( "fmt" "net/http" ) func ErrorResponse(w http.ResponseWriter, status int, err error) { type errorResponse struct { Msg string `json:"msg"` Status int `json:"status"` } _ = Encode(w, status, &errorResponse{ Msg: fmt.Sprintf("%+v", err), Status: status, }) }