copier icon indicating copy to clipboard operation
copier copied to clipboard

How to copy from one data type to another data type with same name?

Open kumarsiva07 opened this issue 6 years ago • 3 comments

// Model
type User struct {
	JoinedAt   time.Time
	ReleavedAt *time.Time
}

// Resource
type UserResource struct {
	JoinedAt   string
	ReceivedAt string
}

Want to copy from User to UserResource.

kumarsiva07 avatar Apr 18 '18 11:04 kumarsiva07

I wonder if that's possible (at the moment), as it would require casting the data types in the copy process.

daluu avatar May 16 '18 23:05 daluu

Can you cast time.Time to string? You need to specify the format somehow (unless it's JSON-specific)

ilius avatar Sep 06 '19 18:09 ilius

hey, i know i'm a little bit late for the party 😅, but i made a PR #115 to make these kind of type conversions via a converter option. Have a look into the PR for an example, should be simliar to yours. cheers tom

tomdevelops avatar Oct 14 '21 16:10 tomdevelops

Closing as it is addressed via #115

uded avatar Jan 06 '23 13:01 uded