package utils type ResCode int64 const ( CodeSuccess ResCode = 1000 + iota CodeInvalidParam CodeUpLoadError CodeStudentInfoEmpty CodeWriteInfoError CodeTooMuchNum CodeServerBusy ) var codeMsgMap = map[ResCode]string{ CodeSuccess: "success", CodeInvalidParam: "请求参数错误", CodeUpLoadError: "上传文件错误", CodeStudentInfoEmpty: "学生信息为空", CodeWriteInfoError: "写入信息错误", CodeTooMuchNum: "请求数量过多", CodeServerBusy: "服务繁忙", } func (c ResCode) Msg() string { msg, ok := codeMsgMap[c] if !ok { msg = codeMsgMap[CodeServerBusy] } return msg }