Skip to content

Commit

Permalink
structure support decode pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
wwqgtxx committed Jul 16, 2023
1 parent ab2785d commit ae4b288
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions common/structure/structure.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ func (d *Decoder) decode(name string, data any, val reflect.Value) error {
return d.decodeFloat(name, data, val)
}
switch kind {
case reflect.Pointer:
if val.IsNil() {
val.Set(reflect.New(val.Type().Elem()))
}
return d.decode(name, data, val.Elem())
case reflect.String:
return d.decodeString(name, data, val)
case reflect.Bool:
Expand Down

0 comments on commit ae4b288

Please sign in to comment.