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

Override String function not works with anonymous struct param #142

Open
rsgok opened this issue Jul 11, 2022 · 1 comment
Open

Override String function not works with anonymous struct param #142

rsgok opened this issue Jul 11, 2022 · 1 comment

Comments

@rsgok
Copy link

rsgok commented Jul 11, 2022

example code

func main() {
	a := A{
		Tag: "tag-A",
		Num: 1,
		InA: InA{
			Id:   100,
			Type: "test",
		},
	}
	spew.Dump(a)
}

type A struct {
	Tag string
	Num int
	InA
}

type InA struct {
	Id   int
	Type string
}

func (t InA) String() string {
	return t.Type
}

unexpected output

(main.A) test
@rsgok
Copy link
Author

rsgok commented Jul 11, 2022

and if struct member not anonymous, go-spew works

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