Skip to content

Commit f38b5d9

Browse files
committed
add comprehensive test suite (96.5% coverage)
1 parent dd7d50a commit f38b5d9

2 files changed

Lines changed: 782 additions & 39 deletions

File tree

convert.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ func structToMap(val reflect.Value, tagName string) map[string]any {
6161
sf := t.Field(i)
6262
fv := val.Field(i)
6363

64-
// Skip unexported fields
65-
if !sf.IsExported() {
64+
// Skip unexported non-embedded fields
65+
if !sf.IsExported() && !sf.Anonymous {
6666
continue
6767
}
6868

@@ -120,7 +120,7 @@ func structValues(val reflect.Value, tagName string) []any {
120120
sf := t.Field(i)
121121
fv := val.Field(i)
122122

123-
if !sf.IsExported() {
123+
if !sf.IsExported() && !sf.Anonymous {
124124
continue
125125
}
126126

@@ -143,7 +143,7 @@ func structNames(val reflect.Value, tagName string) []string {
143143
for i := 0; i < t.NumField(); i++ {
144144
sf := t.Field(i)
145145

146-
if !sf.IsExported() {
146+
if !sf.IsExported() && !sf.Anonymous {
147147
continue
148148
}
149149

@@ -166,7 +166,7 @@ func isZero(val reflect.Value, tagName string) bool {
166166
sf := t.Field(i)
167167
fv := val.Field(i)
168168

169-
if !sf.IsExported() {
169+
if !sf.IsExported() && !sf.Anonymous {
170170
continue
171171
}
172172

@@ -191,7 +191,7 @@ func hasZero(val reflect.Value, tagName string) bool {
191191
sf := t.Field(i)
192192
fv := val.Field(i)
193193

194-
if !sf.IsExported() {
194+
if !sf.IsExported() && !sf.Anonymous {
195195
continue
196196
}
197197

0 commit comments

Comments
 (0)