package _const var RespCode map[int]string const ( RESP_ERR_COMON = 101 RESP_ERR_OK = 0 ) func init() { RespCode[RESP_ERR_OK] = "OK" RespCode[RESP_ERR_COMON] = "Err" } func M(key int) string{ v,ok := RespCode[key] if ok{ return v }else { return "" } }