Browse Source

reflect: add type check to Value.Field()

pull/3561/head
Damian Gryski 2 years ago
committed by Damian Gryski
parent
commit
584a2718d0
  1. 3
      src/reflect/value.go

3
src/reflect/value.go

@ -568,6 +568,9 @@ func (v Value) Elem() Value {
// Field returns the value of the i'th field of this struct.
func (v Value) Field(i int) Value {
if v.Kind() != Struct {
panic(&ValueError{Method: "Field", Kind: v.Kind()})
}
structField := v.typecode.rawField(i)
flags := v.flags
if structField.PkgPath != "" {

Loading…
Cancel
Save