package data import json "github.com/json-iterator/go" type Equip struct { Id int `json:"id"` Quality int `json:"quality"` Type int `json:"type"` Levels int `json:"levels"` SetId int `json:"set_id"` Holes int `json:"holes"` OpenedHoles int `json:"opened_holes"` HoleUnlockType []int `json:"hole_unlock_type"` HoleUnlockArgs []int `json:"hole_unlock_args"` } type EquipTable struct { l []*Equip m map[int]*Equip } func (this *EquipTable) load(buf []byte) error { var err = json.Unmarshal(buf, &this.l) if err != nil { return err } this.m = make(map[int]*Equip) for i := range this.l { this.m[this.l[i].Id] = this.l[i] } return nil } func (this *EquipTable) List() []*Equip { return this.l } func (this *EquipTable) Get(i int) *Equip { return this.l[i] } func (this *EquipTable) Find(id int) *Equip { return this.m[id] }