switchupcb / copygen

Go generator to copy values from type to type and fields from struct to struct (copier without reflection). Generate any code based on types.
https://switchupcb.com/copygen-license-exception/
GNU General Public License v3.0
349 stars 22 forks source link

fix duplicate types #12

Closed f0mster closed 2 years ago

f0mster commented 2 years ago

Match types by parent type. If we have type A that is made from a basic type string, that means that it can be converted to/from string

type A string
var a ="some sting"
var b = B(a)

Also, I fixed the bug (actually there were two bugs in one) that I reported today.

switchupcb commented 2 years ago

Matching by parent type is already supported.

type A string
type B string
type C struct {
   A string
   B string
}

type Copygen Interface {
   /* matches A to C.A and B to C.B */
   toD(A, B) C
}

The var keyword is never relevant because we are dealing with types; not variables.

Feel free to request reopening with an example if this is not the case.