package data import json "github.com/json-iterator/go" type EquipSet struct { Id int `json:"id"` NeedEquips []int `json:"need_equips"` Set2BuffType int `json:"set2_buff_type"` Set2BuffArgs []int `json:"set2_buff_args"` Set2BuffVals []int `json:"set2_buff_vals"` Set3BuffType int `json:"set3_buff_type"` Set3BuffArgs []int `json:"set3_buff_args"` Set3BuffVals []int `json:"set3_buff_vals"` Set4BuffType int `json:"set4_buff_type"` Set4BuffArgs []int `json:"set4_buff_args"` Set4BuffVals []int `json:"set4_buff_vals"` } 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] }