barkimedes / go-deepcopy

A Golang package for doing a deep copy for (just about) anything
MIT License
140 stars 28 forks source link

time.Time problem #6

Open forever-eight opened 1 year ago

forever-eight commented 1 year ago
type User struct {
Name   string `bson:"name"`
Email  string `bson:"email"`
Member Member

}

type Member struct { Name string bson:"name" Type string bson:"type" Date time.Time } u := User{ Name: "Bob", Email: "bob@bob.com", Member: Member{ Name: "Bobby", Date: time.Now(), }, } encryptedOrder := deepcopy.MustAnything(u).(User)

time.Time won't work correctly

forever-eight commented 1 year ago

Output (encryptedOrder) = {Bob bob@bob.com {Bobby 0001-01-01 00:00:00 +0000 UTC}}

onyxg commented 1 year ago

+1

0cnLaroche commented 8 months ago

Same issue here, is the PR going to be merged ?

0cnLaroche commented 7 months ago

@forever-eight @onyxg Maintainer doesn't seem to be active so I forked the repo and made a fix handle the time.Time :

https://github.com/0cnLaroche/go-deepcopy

brunoga commented 7 months ago

FWIIW, I did a from scratch reimplementation of this here: https://github.com/brunoga/deep

Not only it supports time.Time, it also supports all unexported fields as long as they have a supported type.