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

Inline flag for pointer to types #356

Open
wI2L opened this issue Apr 6, 2018 · 1 comment
Open

Inline flag for pointer to types #356

wI2L opened this issue Apr 6, 2018 · 1 comment

Comments

@wI2L
Copy link

wI2L commented Apr 6, 2018

yaml/yaml.go

Line 387 in f7e2331

return nil, errors.New("Option ,inline needs a struct value field")

Hello
For the given type

type ReponseOrRef struct {
	*Response  `yaml:",inline"`
	*Reference `yaml:",inline"`
}

the flag inline cannot be used because the code does not dereference the pointer.
Could I send a PR that check for the kind of the type, and dereference any pointer with Elem() for embedded fields ?

Thanks

EDIT: I read the existing PR too fast, and noticed this has already been mentionned here: #55

@wI2L
Copy link
Author

wI2L commented Apr 6, 2018

I solved it in the meantime using the yaml.Marshaler interface.

func (ror *ReponseOrRef) MarshalYAML() (interface{}, error) {
	if ror.Response != nil {
		return ror.Response, nil
	}
	return ror.Reference, nil
}

Tags are then unncesseray.

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