Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant