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 Map with Embedded pointer to Struct #353

Open
dima-koniaiev-solid opened this issue Mar 26, 2024 · 0 comments
Open

Decoding Struct to Map with Embedded pointer to Struct #353

dima-koniaiev-solid opened this issue Mar 26, 2024 · 0 comments

Comments

@dima-koniaiev-solid
Copy link

Hey, everyone! I still can reproduce the problem with decoding the embedded pointer from this issue. Here is the code to reproduce the problem:

Expected result: map[B:map[Name:]]
Actual result: map[B:0x14000132000]

package main

import (
	"github.com/mitchellh/mapstructure"
	"log"
)

func main() {
	testMap := make(map[string]interface{})
	a := A{&B{}}
	err := mapstructure.Decode(a, &testMap)

	if err != nil {
		panic(err)
	}

	log.Println(testMap)
}

type A struct {
	B *B
}

type B struct {
	Name string
}

If you update this B struct to the following one everything works as expected:

type B struct {
	Test string `mapstructure:",omitempty"`
	Name string
}
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