| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- package code
- import (
- "sync"
- cherryCode "github.com/cherry-game/cherry/code"
- )
- const (
- emptyMsg = ""
- )
- var (
- lock = &sync.RWMutex{}
- dataCodeMaps = make(map[int32]string)
- )
- func AddAll(maps map[int32]string) {
- for k, v := range maps {
- Add(k, v)
- }
- }
- func Add(code int32, message string) {
- lock.Lock()
- defer lock.Unlock()
- dataCodeMaps[code] = message
- }
- func GetMessage(code int32) string {
- msg, found := dataCodeMaps[code]
- if found {
- return msg
- }
- return emptyMsg
- }
- func IsOK(code int32) bool {
- return cherryCode.IsOK(code)
- }
- func IsFail(code int32) bool {
- return cherryCode.IsFail(code)
- }
|