You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
type A struct {
BVal *B
CVal *C
}
type B struct {
CVal *C
}
type C int
var originalC C = 3
originalB := &B{CVal: &originalC}
originalA := A{BVal: originalB, CVal: &originalC}
newA := **Serialize and Deserialize with gob**(originalA)
CVal in originalA is pointing to the same address as CVal in originalB. However, CVal in newA and newB would be a copy of each other without sharing the same address. It would be nice if the references are preserved when serializing.
Justification
Preservation of these references will be useful when using gob on data structures relying on the object tree. These could be indexes to data, efficient storage of data, etc. There will sometimes be the need to persists these data structures to disk or transmit them to another go runtime, most conveniently performed with gob. It could also potentially reduce payload of the serialized data as repetitions could be omitted.
The text was updated successfully, but these errors were encountered:
It would be nice but it is not how gob is defined. It is also a fair amount more expensive. Probably if you need non-tree data structures you should use a different encoder. The definition of gob is basically fixed (immutable) at this point.
Motivation
Consider using gob in the following scenario
CVal
inoriginalA
is pointing to the same address asCVal
inoriginalB
. However,CVal
innewA
andnewB
would be a copy of each other without sharing the same address. It would be nice if the references are preserved when serializing.Justification
Preservation of these references will be useful when using gob on data structures relying on the object tree. These could be indexes to data, efficient storage of data, etc. There will sometimes be the need to persists these data structures to disk or transmit them to another go runtime, most conveniently performed with gob. It could also potentially reduce payload of the serialized data as repetitions could be omitted.
The text was updated successfully, but these errors were encountered: