Skip to content

Commit dd8b872

Browse files
committed
ignore unexported struct field
1 parent 05b354b commit dd8b872

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

go-struct.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,12 @@ func wrapGoStruct(structVar, structE reflect.Value, structT reflect.Type) map[st
3737
r := make(map[string]interface{})
3838
for i:=0; i<structT.NumField(); i++ {
3939
strField := structT.Field(i)
40+
fv := structE.Field(i)
41+
if !fv.CanInterface() {
42+
continue
43+
}
4044
name := strField.Name
4145
name = lowerFirst(name)
42-
fv := structE.Field(i)
4346
r[name] = toValue(fv.Interface())
4447
}
4548

0 commit comments

Comments
 (0)