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

Decoding to maps with multiple indirection results in an error #347

@sagikazarmark

Description

@sagikazarmark

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions