yfcck opened a new issue, #1929: URL: https://github.com/apache/fury/issues/1929
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/fury/issues) and found no similar issues. ### Version fury: v0.8.0 go: 1.23.1 ``` import ( "example/fury" "fmt" ) // 原始版本的 Person type PersonV1 struct { Name string Age int Hobbies []string } // 新版本的 Person,添加了新字段 type PersonV2 struct { Name string Age int Hobbies []string Email string // 新增字段 Address string // 新增字段 IsMarried bool // 新增字段 } func main() { fu := fury.NewFury(true) fu.RegisterTagType("example.PersonV1", PersonV1{}) fu.RegisterTagType("example.PersonV2", PersonV2{}) // 创建并序列化V1数据 personV1 := PersonV1{ Name: "张三", Age: 25, Hobbies: []string{"读书", "运动"}, } var err error var bytesV1,bytesV2 []byte bytesV1, err = fu.Marshal(personV1) if err != nil { panic(err) } var personV2 PersonV2 if err = fu.Unmarshal(bytesV1, &personV2); err != nil { panic(err) } fmt.Println("\n===测试向前兼容性(旧数据读取到新结构)===",personV2) personV2.Email="[email protected]" personV2.Address="ABC" personV2.IsMarried= true bytesV2, err = fu.Marshal(personV2) if err != nil { panic(err) } if err = fu.Unmarshal(bytesV2,&personV1);err!=nil { panic(err) // <----------------------------------------- got error } fmt.Println("\n===测试向后兼容性(新数据读取到旧结构)===",personV1) } ``` ===测试向前兼容性(旧数据读取到新结构)=== {张三 25 [读书 运动] false} panic: reflect: Field index out of range goroutine 1 [running]: reflect.Value.Field({0x113180?, 0xc00001a3f0?, 0xc00006bb90?}, 0x1488d?) C:/go/src/reflect/value.go:1273 +0x92 example/fury.(*structSerializer).Read(0xc000080100, 0xc0000840f0, 0xc000084230, {0x30?, 0x0?}, {0x113180?, 0xc00001a3f0?, 0xc000085f80?}) D:/example/fury/struct.go:97 +0x2a9 example/fury.(*Fury).readData(0xc0000840f0, 0xc000084230, {0x113180?, 0xc00001a3f0?, 0xe2eff?}, {0x0, 0x0}) D:/example/fury/fury.go:464 +0x379 example/fury.(*Fury).readReferencableBySerializer(0xc0000840f0, 0xc000084230, {0x113180?, 0xc00001a3f0?, 0x50?}, {0x0, 0x0}) D:/example/fury/fury.go:385 +0xd9 example/fury.(*Fury).ReadReferencable(...) D:/example/fury/fury.go:376 example/fury.(*Fury).Deserialize(0xc0000840f0, 0xc000084230, {0xff040?, 0xc00001a3f0?}, {0x0?, 0xffd80?, 0x0?}) D:/example/fury/fury.go:369 +0x32d example/fury.(*Fury).Unmarshal(...) D:/example/fury/fury.go:318 main.main() D:/example/main.go:61 +0x3fe exit status 2 ### Component(s) Go ### Minimal reproduce step No response ### What did you expect to see? No response ### What did you see instead? No response ### Anything Else? _No response_ ### Are you willing to submit a PR? - [ ] I'm willing to submit a PR! -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
