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

Implement TextMarshaler and TextUnmarshaler interfaces #26

Open
dirkmc opened this issue Nov 19, 2021 · 0 comments
Open

Implement TextMarshaler and TextUnmarshaler interfaces #26

dirkmc opened this issue Nov 19, 2021 · 0 comments

Comments

@dirkmc
Copy link
Contributor

dirkmc commented Nov 19, 2021

This would broaden the range of use cases for address.Address, for example it is needed by the toml encoder.

// TextMarshaler is the interface implemented by an object that can
// marshal itself into a textual form.
//
// MarshalText encodes the receiver into UTF-8-encoded text and returns the result.
type TextMarshaler interface {
	MarshalText() (text []byte, err error)
}

// TextUnmarshaler is the interface implemented by an object that can
// unmarshal a textual representation of itself.
//
// UnmarshalText must be able to decode the form generated by MarshalText.
// UnmarshalText must copy the text if it wishes to retain the text
// after returning.
type TextUnmarshaler interface {
	UnmarshalText(text []byte) error
}
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