Hello Everyone,
I've encountered a problem when I was trying to serialize pointers in a slice using gob package in golang. I tried to follow the example in
http://blog.golang.org/gobs-of-dataThe original code defines two struts
type P struct {
X, Y, Z int
Name string
}
type Q struct {
X, Y *int32
Name string
}
Encode P and Decode Q works great for me. However, when I try to encode []P and decode []Q. It won't work unless I revise the two pointers X, Y *int32 as X, Y int32.
How can I solve this problem? I have put the error code here
http://play.golang.org/p/MTmMb-1DdJIf you change X, Y *int32 in the above code to X, Y int32. It will work but from my understanding of reflection, both should work with Gob.
Thank you very much for help.
Cheers,
Eric