//---------------------------------------------------------- Set Field value func _set(tblname string, rowname string, fieldname string, value string) { // store hashing h_rowname := naming.FNV1a(rowname) h_fieldname := naming.FNV1a(fieldname) h_tblname := naming.FNV1a(tblname) _hashtbl[h_rowname] = rowname _hashtbl[h_fieldname] = fieldname _hashtbl[h_tblname] = tblname // tbl := _tables[h_tblname] if tbl == nil { tbl = &Table{} tbl.Records = make(map[uint32]*Record) _tables[h_tblname] = tbl } rec := tbl.Records[h_rowname] if rec == nil { rec = &Record{} rec.Fields = make(map[uint32]string) tbl.Records[h_rowname] = rec } rec.Fields[h_fieldname] = value }
func TestParser(t *testing.T) { fmt.Println("读取 部落大厅等级 LEVEL:20 Field:金库") fmt.Println(GetInt("部落大厅等级", "20", "金库")) fmt.Println(GetString("建筑规格", "锻造室", "占用格子数")) hash := naming.FNV1a("锻造室") fmt.Println(Query(hash)) }
func TestEstate(t *testing.T) { data := &estates.Manager{} e1 := &estates.Estate{TYPE: naming.FNV1a("工人小屋"), Ready: true} data.Append(100, e1) data.UserId = 1 fmt.Println("Set") Set(estates.COLLECTION, data) var value *estates.Manager Get(estates.COLLECTION, 1, &value) fmt.Println("Get:", value) var all []estates.Manager GetAll(estates.COLLECTION, &all) fmt.Println("GetAll") fmt.Println(value) }
func _get(tblname string, rowname string, fieldname string) string { return _gethash(naming.FNV1a(tblname), naming.FNV1a(rowname), naming.FNV1a(fieldname)) }