-
Notifications
You must be signed in to change notification settings - Fork 43
/
AImatch.go
60 lines (46 loc) · 900 Bytes
/
AImatch.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package excel
import (
"encoding/json"
"io/ioutil"
"sync"
log "github.com/cihub/seelog"
)
type AImatchData struct {
Id uint64
Name string
Value float32
}
var AImatch map[uint64]AImatchData
var AImatchLock sync.RWMutex
func LoadAImatch(){
AImatchLock.Lock()
defer AImatchLock.Unlock()
data,err := ioutil.ReadFile("../res/excel/AImatch.json")
if err != nil {
log.Error("ReadFile err: ", err)
return
}
err = json.Unmarshal(data, &AImatch)
if err != nil {
log.Error("Unmarshal err: ", err)
return
}
}
func GetAImatchMap() map[uint64]AImatchData {
AImatchLock.RLock()
defer AImatchLock.RUnlock()
AImatch2 := make(map[uint64]AImatchData)
for k, v := range AImatch{
AImatch2[k] = v
}
return AImatch2
}
func GetAImatch(key uint64) (AImatchData, bool) {
AImatchLock.RLock()
defer AImatchLock.RUnlock()
val, ok := AImatch[key]
return val, ok
}
func GetAImatchMapLen() int {
return len(AImatch)
}