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
Ran into a case in a test on qri where we needed to deep copy a dataset. We are relying on github.com/jinzhu/copier for this functionality, and it's working fine.
While working on the problem, I assumed that dataset.Assign() would create new copies of the dataset for me, in the same way that Assign works in javascript. This however, wasn't the case. Changing a field in an underlying component (such as ds.Structure.Format) would change the field in both datasets.
If we find that we end up needing to deep copy datasets more, we should add a copy function that behaves much in the way that our config.Copy works over in the config packages in qri: https://github.com/qri-io/qri/blob/master/config/config.go
// Copy returns a deep copy of the dataset structure
func (d *Dataset) Copy() *Dataset
The text was updated successfully, but these errors were encountered:
Ran into a case in a test on
qri
where we needed to deep copy a dataset. We are relying ongithub.com/jinzhu/copier
for this functionality, and it's working fine.While working on the problem, I assumed that
dataset.Assign()
would create new copies of the dataset for me, in the same way thatAssign
works in javascript. This however, wasn't the case. Changing a field in an underlying component (such asds.Structure.Format
) would change the field in both datasets.If we find that we end up needing to deep copy datasets more, we should add a copy function that behaves much in the way that our
config.Copy
works over in theconfig
packages inqri
: https://github.com/qri-io/qri/blob/master/config/config.goThe text was updated successfully, but these errors were encountered: