package responses import "encoding/json" type ErrorResponse struct { Code int `json:"code"` Msg string `json:"msg"` } func (e *ErrorResponse) Error() string { marshal, err := json.Marshal(e) if err != nil { return err.Error() } return string(marshal) } func NewErrorResp(code int, msg error) *ErrorResponse { return &ErrorResponse{ Code: code, Msg: msg.Error(), } }