game/common/serialization/serialization_test.go

36 lines
661 B
Go
Raw Normal View History

package serialization
import (
2025-06-04 23:11:32 +08:00
"fmt"
"game/common/model/user"
"testing"
2025-06-04 23:11:32 +08:00
"time"
)
func Test_zz(t *testing.T) {
2025-06-04 23:11:32 +08:00
us := &user.UserAccount{
ID: 17,
Username: "test001",
Password: "123456",
Email: "",
Phone: "",
DeviceID: "",
LastLoginIP: "127.0.0.1",
LastLoginTime: time.Now(),
Status: 0,
RegisterIP: "",
RegisterTime: time.Now(),
}
maps := StructToMap(us)
t.Log(maps)
mapString := make(map[string]string)
for key, value := range maps {
mapString[key] = fmt.Sprintf("%v", value)
}
var err error
2025-06-04 23:11:32 +08:00
us, err = MapToStruct[user.UserAccount](mapString)
t.Log(err)
t.Log(us)
}