blob: e5bd21fb771283954265298a674726eae328d539 [file] [log] [blame]
package test
import (
"encoding"
"strings"
)
func init() {
testCases = append(testCases,
(*map[stringKeyType]string)(nil),
(*map[structKeyType]string)(nil),
)
}
type stringKeyType string
func (k stringKeyType) MarshalText() ([]byte, error) {
return []byte("MANUAL__" + k), nil
}
func (k *stringKeyType) UnmarshalText(text []byte) error {
*k = stringKeyType(strings.TrimPrefix(string(text), "MANUAL__"))
return nil
}
var _ encoding.TextMarshaler = stringKeyType("")
var _ encoding.TextUnmarshaler = new(stringKeyType)
type structKeyType struct {
X string
}
func (k structKeyType) MarshalText() ([]byte, error) {
return []byte("MANUAL__" + k.X), nil
}
func (k *structKeyType) UnmarshalText(text []byte) error {
k.X = strings.TrimPrefix(string(text), "MANUAL__")
return nil
}
var _ encoding.TextMarshaler = structKeyType{}
var _ encoding.TextUnmarshaler = &structKeyType{}