XinYeYouKu/app/constants/errorcode/error_code.go

42 lines
661 B
Go
Raw Normal View History

2024-06-07 18:24:56 +08:00
package errorcode
const (
//成功
Success = 200
//参数错误
ParamError = 400
//未经授权
NotAuth = 401
//请求被禁止
Forbidden = 403
//找不到页面
NotFound = 404
//系统错误
SystemError = 500
)
var MsgEN = map[int]string{
Success: "success",
ParamError: "param error",
NotAuth: "not authorized",
Forbidden: "forbidden",
NotFound: "not found",
SystemError: "system error",
}
var MsgMap map[string]map[int]string = map[string]map[int]string{"en": MsgEN}
func GetMsg(code int, local string) string {
if local == "" {
local = "en"
}
if msg, ok := MsgMap[local][code]; ok {
return msg
}
return ""
}