Skip to content

Commit d16ad56

Browse files
Merge pull request #336 from moveyield/master
refactor: use reflect.TypeFor
2 parents 3f97615 + 5d0fe04 commit d16ad56

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

opensca/sca/java/xml/marshal.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -415,9 +415,9 @@ func (p *printer) popPrefix() {
415415
}
416416

417417
var (
418-
marshalerType = reflect.TypeOf((*Marshaler)(nil)).Elem()
419-
marshalerAttrType = reflect.TypeOf((*MarshalerAttr)(nil)).Elem()
420-
textMarshalerType = reflect.TypeOf((*encoding.TextMarshaler)(nil)).Elem()
418+
marshalerType = reflect.TypeFor[Marshaler]()
419+
marshalerAttrType = reflect.TypeFor[MarshalerAttr]()
420+
textMarshalerType = reflect.TypeFor[encoding.TextMarshaler]()
421421
)
422422

423423
// marshalValue writes one or more XML elements representing val.

opensca/sca/java/xml/read.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -303,10 +303,10 @@ func (d *Decoder) unmarshalAttr(val reflect.Value, attr Attr) error {
303303
}
304304

305305
var (
306-
attrType = reflect.TypeOf(Attr{})
307-
unmarshalerType = reflect.TypeOf((*Unmarshaler)(nil)).Elem()
308-
unmarshalerAttrType = reflect.TypeOf((*UnmarshalerAttr)(nil)).Elem()
309-
textUnmarshalerType = reflect.TypeOf((*encoding.TextUnmarshaler)(nil)).Elem()
306+
attrType = reflect.TypeFor[Attr]()
307+
unmarshalerType = reflect.TypeFor[Unmarshaler]()
308+
unmarshalerAttrType = reflect.TypeFor[UnmarshalerAttr]()
309+
textUnmarshalerType = reflect.TypeFor[encoding.TextUnmarshaler]()
310310
)
311311

312312
const (

opensca/sca/java/xml/typeinfo.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const (
4848

4949
var tinfoMap sync.Map // map[reflect.Type]*typeInfo
5050

51-
var nameType = reflect.TypeOf(Name{})
51+
var nameType = reflect.TypeFor[Name]()
5252

5353
// getTypeInfo returns the typeInfo structure with details necessary
5454
// for marshaling and unmarshaling typ.

0 commit comments

Comments
 (0)