1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- package code
- import (
- mhayaCode "github.com/mhaya/code"
- "sync"
- )
- const (
- emptyMsg = ""
- )
- var (
- lock = &sync.RWMutex{}
- resultMaps = 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()
- resultMaps[code] = message
- }
- func GetMessage(code int32) string {
- msg, found := resultMaps[code]
- if found {
- return msg
- }
- return emptyMsg
- }
- func IsOK(code int32) bool {
- return mhayaCode.IsOK(code)
- }
- func IsFail(code int32) bool {
- return mhayaCode.IsFail(code)
- }
|