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 to maps with multiple indirection results in an error #347

Open
sagikazarmark opened this issue Dec 8, 2023 · 0 comments
Open

Comments

@sagikazarmark
Copy link

As the title says, when trying to decode a pointer of a pointer of any supported type to a map, mapstructure returns an error saying '' expected a map, got 'ptr'.

The following code reproduces the issue on the latest main branch:

	type Struct struct {
		Foo string
	}

	s := &Struct{
		Foo: "bar",
	}

	ss := &s
	sss := &ss

	var m map[string]interface{}

	if err := Decode(sss, &m); err != nil {
		panic(err)
	}

The relevant code (here) checks for one level of indirection.

See spf13/viper#1706 for more details

@sagikazarmark sagikazarmark changed the title Decoding structs to maps with multiple indirection results in an error Decoding maps with multiple indirection results in an error Dec 8, 2023
@sagikazarmark sagikazarmark changed the title Decoding maps with multiple indirection results in an error Decoding to maps with multiple indirection results in an error Dec 8, 2023
sagikazarmark added a commit to sagikazarmark/mapstructure that referenced this issue Dec 8, 2023
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
sagikazarmark added a commit to go-viper/mapstructure that referenced this issue Dec 18, 2023
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
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

Successfully merging a pull request may close this issue.

1 participant