package baseroom // type PlayerLog struct { // UId int64 `json:"uid"` // 玩家id // Seat int `json:"seat"` // 座位号 // CostItem []Item `json:"cost_item"` // 消耗物品 // } // // type GameLogT struct { // Players []*PlayerLog `json:"players"` // 玩家数据 // } // // type StructM struct { // Players []map[string]interface{} `json:"players"` // 玩家数据 // } // // type B struct { // I int `json:"i"` // } // // type B2 struct { // I2 int `json:"i2"` // } // // func (b *B) GetId() int { // return b.I // } // // type C struct { // *B // *B2 // Z int `json:"z"` // } // // // 测试添加金币 // func TestStruct(t *testing.T) { // //game := new(BaseGameLog) // //game.Players = append(game.Players, &BasePlayerLog{UId: 1, Seat: 0, CostItem: []ItemLog{{Id: 10, Num: 10}, {Id: 11, Num: 11}}}) // //game.Players = append(game.Players, &BasePlayerLog{UId: 2, Seat: 1, CostItem: []ItemLog{{Id: 20, Num: 20}, {Id: 21, Num: 21}}}) // //b1, _ := json.Marshal(game) // m := new(StructM) // p1 := map[string]interface{}{"uid": 1, "seat": 0, "cost_item": []Item{{Id: 10, Num: 10}, {Id: 11, Num: 11}}} // p2 := map[string]interface{}{"uid": 2, "seat": 1, "cost_item": []Item{{Id: 20, Num: 20}, {Id: 21, Num: 21}}} // m.Players = append(m.Players, p1) // m.Players = append(m.Players, p2) // b2, _ := json.Marshal(m) // // game := new(GameLogT) // _ = json.Unmarshal(b2, game) // b1, _ := json.Marshal(game) // // t.Log(string(b1)) // t.Log(string(b2)) // // c := C{B: &B{I: 10}, B2: &B2{I2: 12}, Z: 1} // sc, _ := json.Marshal(c) // t.Log(string(sc)) // }