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

[feature] extended Marshaler interface with passing extra parameters #999

Open
metux opened this issue Oct 19, 2023 · 0 comments
Open

[feature] extended Marshaler interface with passing extra parameters #999

metux opened this issue Oct 19, 2023 · 0 comments

Comments

@metux
Copy link

metux commented Oct 19, 2023

There are cases where objects could be marshaled in different ways,.especially those with custom marshalers.

Example: i've got an recursive dictionary with extra features like defaults and variable substitution. Depending on the actual use case, marshaling could be done eg w/ or w/o merging defaults, or w/ or w/o resolving variables.

Adding new frontend functions with extra parameters (eg. yaml.MarshalExt(...)) simple. But the Marshaler interface has no means for passing extra parameters down to the individual object.

Proposal: extended Marshaler interface, eg.

type MarshalerExr interface {
MarshalYAMLExt(args map[string] string) (interface{}, error)
}

Of course there yet needs to be some convention on naming these args keys, in order to prevent clashes between different object types.

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