encoder: support TextMarshaler (#522)

Fixes #521
This commit is contained in:
Thomas Pelletier
2021-04-22 10:13:41 -04:00
committed by GitHub
parent 2b1c52dddd
commit e443b4fdb8
3 changed files with 52 additions and 16 deletions
@@ -612,16 +612,6 @@ func (x *IntOrString) MarshalTOML() ([]byte, error) {
return []byte(s), nil
}
type textMarshaler struct {
FirstName string
LastName string
}
func (m textMarshaler) MarshalText() ([]byte, error) {
fullName := fmt.Sprintf("%s %s", m.FirstName, m.LastName)
return []byte(fullName), nil
}
func TestUnmarshalTextMarshaler(t *testing.T) {
var nested = struct {
Friends textMarshaler `toml:"friends"`