ignore unaddressable fields
This commit is contained in:
parent
9a6db08a25
commit
bcadfd8b71
4
field.go
4
field.go
@ -189,6 +189,10 @@ func fieldValues(v reflect.Value) []Field {
|
|||||||
}
|
}
|
||||||
|
|
||||||
vfi := v.Field(i)
|
vfi := v.Field(i)
|
||||||
|
if tfi.Anonymous && !vfi.CanAddr() {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
vfi = unpackValue(vfi, pointer|iface|anytype)
|
vfi = unpackValue(vfi, pointer|iface|anytype)
|
||||||
switch {
|
switch {
|
||||||
case tfi.Anonymous:
|
case tfi.Anonymous:
|
||||||
|
|||||||
@ -252,9 +252,7 @@ func TestField(t *testing.T) {
|
|||||||
v.Foo = 21
|
v.Foo = 21
|
||||||
v.Bar = 42
|
v.Bar = 42
|
||||||
f := bind.FieldValues(v)
|
f := bind.FieldValues(v)
|
||||||
if len(f) != 2 ||
|
if len(f) != 1 || f[0].Name() != "bar" || f[0].Value() != 42 {
|
||||||
f[0].Name() != "foo" || f[0].Value() != 21 ||
|
|
||||||
f[1].Name() != "bar" || f[1].Value() != 42 {
|
|
||||||
t.Fatal()
|
t.Fatal()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user