package util import ( "fmt" "log" "runtime" ) // Return for return type type Return interface{} // Status of API return type Status struct { Status string `json:"status"` Message string `json:"message"` Data interface{} `json:"data"` ErrorCode string `json:"error_code"` Type string `json:"type"` } // NewOkStatus return ok status func NewOkStatus() *Status { return &Status{Status: "Ok"} } // NewErrorStatus return error status func NewErrorStatus() *Status { _, file, no, ok := runtime.Caller(1) if ok { log.Println(fmt.Sprintf("Error: called from %s#%d\n", file, no)) } return &Status{Status: "Error"} } func (s *Status) SetData(data interface{}) *Status { s.Data = data return s } func (s *Status) SetMessage(message string) *Status { s.Message = message return s } func (s *Status) SetType(t string) *Status { s.Type = t return s } func (s *Status) SetErrorCode(e string) *Status { s.ErrorCode = e return s } func (s *Status) Error() string { return s.Message }