Re: [go-nuts] DeepCloning a datastructure
And, I realized just after posting that your data structure has private fields in it as https://github.com/mohae/deepcopy won't work on those. On Thu, Apr 16, 2020 at 9:02 PM Hugh Emberson wrote: > On Thu, Apr 16, 2020 at 2:07 PM Marc Schöchlin wrote: > >> i am searching for a convenient way to deep-clone a nested datastructure. >> > > I've used https://github.com/mohae/deepcopy with some success. YMMV. > > Regards, > Hugh > > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAJ5gAGmwjnqOtHeE17ScyM7SUZymrb9D-MJ4VG%3DD9Zo6oKesxQ%40mail.gmail.com.
Re: [go-nuts] DeepCloning a datastructure
On Thu, Apr 16, 2020 at 2:07 PM Marc Schöchlin wrote: > i am searching for a convenient way to deep-clone a nested datastructure. > I've used https://github.com/mohae/deepcopy with some success. YMMV. Regards, Hugh -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAJ5gAGmUQYRW04%3DkSM2DfiMQhVCQg6xPnZ8ohaOGBPjsaUF8nQ%40mail.gmail.com.
[go-nuts] DeepCloning a datastructure
Hello List, i am searching for a convenient way to deep-clone a nested datastructure. My data structure looks like this: (map[string]map[string]*processing.AccountingSet) (len=1) { (string) (len=16) "foo1.bar.com:443": (map[string]*processing.AccountingSet) (len=1) { (string) (len=3) "all": (*processing.AccountingSet)(0xc90060)({ count: (int64) 90, sum: (int64) 8001480, codes: (map[int]int) (len=1) { (int) 301: (int) 90 }, classes: (map[int]int) (len=6) { (int) 0: (int) 90, (int) 50: (int) 0, (int) 500: (int) 0, (int) 1000: (int) 0, (int) 6000: (int) 0, (int) 3: (int) 0 } }) } } How can i make a exact, deep, and completely independent copy of that structure? What i tried: (c.stats contains the mentioned data structure which should by copied to c.stats) import "github.com/ulule/deepcopier" c.lastStats = map[string]map[string]*AccountingSet{} err = deepcopier.Copy(c.stats).To(c.lastStats) if err != nil { glog.Errorf("unable to clone : '%s'", err.Error()) } This doesn't work. The target structure is empty after the copy operation. Regards Marc -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/c860e575-28a0-1642-b097-28f592a83e43%40256bit.org.