package data import json "github.com/json-iterator/go" type EquipSet struct { Id int `json:"id"` } type EquipSetTable struct { l []*EquipSet m map[int]*EquipSet } func (this *EquipSetTable) load(buf []byte) error { var err = json.Unmarshal(buf, &this.l) if err != nil { return err } this.m = make(map[int]*EquipSet) for i := range this.l { this.m[this.l[i].Id] = this.l[i] } return nil } func (this *EquipSetTable) List() []*EquipSet { return this.l } func (this *EquipSetTable) Get(i int) *EquipSet { return this.l[i] } func (this *EquipSetTable) Find(id int) *EquipSet { return this.m[id] }