Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decoding struct to struct #355

Open
dennis-dko opened this issue May 6, 2024 · 0 comments
Open

Decoding struct to struct #355

dennis-dko opened this issue May 6, 2024 · 0 comments

Comments

@dennis-dko
Copy link

Hello,

I want to decode the values from a struct to another struct, it works for all primitive datatypes but not for custom types like the Foobar example which uses the World struct as new custom type for Hello.

type World struct {
    time.Time
} 

type Foobar struct {
    Hello World 
} 

type Dest struct {
  CurrentTime World `mapstructure:"Hello"`
} 


src := Foobar{
 Hello: time.Now(), 
} 

var dest Dest

mapstructure.Decode(src, &dest) 

I have the same problem with sql.NullString.

The problem is I have to decode the complete struct in the hook function and I hope I can do it easier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant