易云轻量版服务端
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

33 行
682 B

  1. // http_result
  2. package utils
  3. import "encoding/json"
  4. type HttpResult struct {
  5. Code int8
  6. Msg string
  7. Data interface{}
  8. }
  9. func BuildSuccess() (string) {
  10. httpResult := new(HttpResult)
  11. httpResult.Code = 0
  12. httpResultByte,_ :=json.Marshal(httpResult)
  13. return string(httpResultByte)
  14. }
  15. func BuildFail(msg string) (string) {
  16. httpResult := new(HttpResult)
  17. httpResult.Code = -1
  18. httpResult.Msg = msg
  19. httpResultByte,_ :=json.Marshal(httpResult)
  20. return string(httpResultByte)
  21. }
  22. func BuildSuccessData(data interface{}) (string) {
  23. httpResult := new(HttpResult)
  24. httpResult.Code = 0
  25. httpResult.Data = data
  26. httpResultByte,_ :=json.Marshal(httpResult)
  27. return string(httpResultByte)}