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

unsupported type for squash: interface #186

Open
andig opened this issue Apr 30, 2020 · 2 comments · May be fixed by #325
Open

unsupported type for squash: interface #186

andig opened this issue Apr 30, 2020 · 2 comments · May be fixed by #325

Comments

@andig
Copy link

andig commented Apr 30, 2020

I would like to be able to build the target struct that decode maps into across different contributing pieces that are only stitched together at runtime. My approach for doing this is something like this where Bar extends a config stack by adding a Bar element around the wrapped config contained within:

type Wrapped interface{}

func (c *Bar) Stack(in interface{}) interface{} {
	out = struct {
		Wrapped `mapstructure:",squash"`
		Bar     string
	}{
		Wrapped: in,
	}
	return out
}

I'm using an anonymous interface as there is no anonymous struct. Unfortunately, mapstructure cannot decode squashed interfaces containing structs:

* Wrapped: unsupported type for squash: interface

Source code is there:

fmt.Errorf("%s: unsupported type for squash: %s", fieldType.Name, fieldKind))

Is that something that could be changed? Would be happy to look into a PR here.

@mitchellh
Copy link
Owner

Yes this should be fixable, if you want to take a stab at it I'd appreciate it.

@m1k1o
Copy link

m1k1o commented Apr 14, 2023

@andig @mitchellh Created PR to add this functionality: #325

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.

3 participants