Skip to content

Commit 1ec84c1

Browse files
authored
Merge pull request #6 from matsuri-tech/issue-5
fix: TypeOf may return nil
2 parents 702587e + 03313d0 commit 1ec84c1

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

marshal.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ func scanToMap(val interface{}) (map[string]interface{}, error) {
4545

4646
m[fieldName] = v
4747
} else if ival.Kind() == reflect.Interface {
48-
if reflect.TypeOf(ival.Interface()).Kind() == reflect.Struct {
48+
t := reflect.TypeOf(ival.Interface())
49+
if t == nil {
50+
m[fieldName] = nil
51+
} else if t.Kind() == reflect.Struct {
4952
// PERF: 再帰をやめる
5053
v, err := scanToMap(ival.Interface())
5154
if err != nil {

0 commit comments

Comments
 (0)