...
1 package tests
2
3 type KeyWithEncodingMarshaler int
4
5 func (f KeyWithEncodingMarshaler) MarshalText() (text []byte, err error) {
6 return []byte("hello"), nil
7 }
8
9 func (f *KeyWithEncodingMarshaler) UnmarshalText(text []byte) error {
10 if string(text) == "hello" {
11 *f = 5
12 }
13 return nil
14 }
15
16
17 type KeyWithEncodingMarshalers map[KeyWithEncodingMarshaler]string
18
19 var mapWithEncodingMarshaler KeyWithEncodingMarshalers = KeyWithEncodingMarshalers{5: "hello"}
20 var mapWithEncodingMarshalerString = `{"hello":"hello"}`
21
View as plain text