Skip to content

Commit

Permalink
Fix panic when printing non-reference types
Browse files Browse the repository at this point in the history
  • Loading branch information
lherman-cs committed Oct 31, 2020
1 parent 16ceb45 commit 640eeb0
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pkg/prop/prop.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,18 @@ func prettifyStruct(i interface{}) string {
value := obj.Field(i)

padding := strings.Repeat(" ", level)
if value.Kind() == reflect.Struct {
switch value.Kind() {
case reflect.Struct:
rows = append(rows, fmt.Sprintf("%s%v:", padding, field.Name))
addRows(level+1, value)
} else {
case reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Ptr, reflect.Slice:
if value.IsNil() {
rows = append(rows, fmt.Sprintf("%s%v: any", padding, field.Name))
} else {
rows = append(rows, fmt.Sprintf("%s%v: %v", padding, field.Name, value))
}
default:
rows = append(rows, fmt.Sprintf("%s%v: %v", padding, field.Name, value))
}
}
}
Expand Down

0 comments on commit 640eeb0

Please sign in to comment.