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

Squash cause *time.Time set to zero #228

Closed
wenerme opened this issue Jan 5, 2021 · 4 comments
Closed

Squash cause *time.Time set to zero #228

wenerme opened this issue Jan 5, 2021 · 4 comments

Comments

@wenerme
Copy link

wenerme commented Jan 5, 2021

type A struct {
	AA
}
type AA struct {
	T *time.Time
}
func TestMapSquash(t *testing.T) {
	v := time.Now()
	in := &AA{
		T: &v,
	}
	out := &A{}
	d, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{
		Squash: true,
		Result: out,
	})
	assert.NoError(t, err)
	assert.NoError(t, d.Decode(in))
	// these failed
	assert.True(t, v.Equal(*out.T))
	assert.False(t, out.T.IsZero())
}
@wenerme
Copy link
Author

wenerme commented Jan 5, 2021

in decodeMapFromStruct will decode the time.Time to map, but there is no exported field, so and empty map is returned, this happened before Hook, no way to handle this.

@mitchellh
Copy link
Owner

This is fixed with #232 will release a patch release. Thank you VERY much for the test.

@anistark
Copy link

When's the release for this fix coming? @mitchellh

@mitchellh
Copy link
Owner

Just released, 1.4.1

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

3 participants