model: 修复 nil map

pull/1/head
miraclesu 2017-02-17 14:19:35 +08:00
parent c030862b9c
commit a615b32ca9
2 changed files with 2 additions and 2 deletions

View File

@ -43,11 +43,11 @@ func GetGroups(nid string) (groups map[string]*Group, err error) {
} }
count := len(resp.Kvs) count := len(resp.Kvs)
groups = make(map[string]*Group, count)
if count == 0 { if count == 0 {
return return
} }
groups = make(map[string]*Group, count)
for _, g := range resp.Kvs { for _, g := range resp.Kvs {
group := new(Group) group := new(Group)
if e := json.Unmarshal(g.Value, group); e != nil { if e := json.Unmarshal(g.Value, group); e != nil {

View File

@ -98,11 +98,11 @@ func GetJobs() (jobs map[string]*Job, err error) {
} }
count := len(resp.Kvs) count := len(resp.Kvs)
jobs = make(map[string]*Job, count)
if count == 0 { if count == 0 {
return return
} }
jobs = make(map[string]*Job, count)
for _, j := range resp.Kvs { for _, j := range resp.Kvs {
job := new(Job) job := new(Job)
if e := json.Unmarshal(j.Value, job); e != nil { if e := json.Unmarshal(j.Value, job); e != nil {