}
var (
- marshalerType = reflect.TypeOf((*Marshaler)(nil)).Elem()
- marshalerAttrType = reflect.TypeOf((*MarshalerAttr)(nil)).Elem()
- textMarshalerType = reflect.TypeOf((*encoding.TextMarshaler)(nil)).Elem()
+ marshalerType = reflect.TypeFor[Marshaler]()
+ marshalerAttrType = reflect.TypeFor[MarshalerAttr]()
+ textMarshalerType = reflect.TypeFor[encoding.TextMarshaler]()
)
// marshalValue writes one or more XML elements representing val.
}
var (
- attrType = reflect.TypeOf(Attr{})
- unmarshalerType = reflect.TypeOf((*Unmarshaler)(nil)).Elem()
- unmarshalerAttrType = reflect.TypeOf((*UnmarshalerAttr)(nil)).Elem()
- textUnmarshalerType = reflect.TypeOf((*encoding.TextUnmarshaler)(nil)).Elem()
+ attrType = reflect.TypeFor[Attr]()
+ unmarshalerType = reflect.TypeFor[Unmarshaler]()
+ unmarshalerAttrType = reflect.TypeFor[UnmarshalerAttr]()
+ textUnmarshalerType = reflect.TypeFor[encoding.TextUnmarshaler]()
)
const (
var badPathTests = []struct {
v, e any
}{
- {&BadPathTestA{}, &TagPathError{reflect.TypeOf(BadPathTestA{}), "First", "items>item1", "Second", "items"}},
- {&BadPathTestB{}, &TagPathError{reflect.TypeOf(BadPathTestB{}), "First", "items>item1", "Second", "items>item1>value"}},
- {&BadPathTestC{}, &TagPathError{reflect.TypeOf(BadPathTestC{}), "First", "", "Second", "First"}},
- {&BadPathTestD{}, &TagPathError{reflect.TypeOf(BadPathTestD{}), "First", "", "Second", "First"}},
+ {&BadPathTestA{}, &TagPathError{reflect.TypeFor[BadPathTestA](), "First", "items>item1", "Second", "items"}},
+ {&BadPathTestB{}, &TagPathError{reflect.TypeFor[BadPathTestB](), "First", "items>item1", "Second", "items>item1>value"}},
+ {&BadPathTestC{}, &TagPathError{reflect.TypeFor[BadPathTestC](), "First", "", "Second", "First"}},
+ {&BadPathTestD{}, &TagPathError{reflect.TypeFor[BadPathTestD](), "First", "", "Second", "First"}},
}
func TestUnmarshalBadPaths(t *testing.T) {