mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
add FieldByName to the interface of reflect.StructType
R=rsc DELTA=34 (33 added, 0 deleted, 1 changed) OCL=31752 CL=31754
This commit is contained in:
parent
1399badb02
commit
a93c5c8550
2 changed files with 34 additions and 1 deletions
|
|
@ -214,9 +214,18 @@ func TestAll(t *testing.T) { // TODO(r): wrap up better
|
|||
styp := etyp.(*StructType);
|
||||
f := styp.Field(0);
|
||||
testType(t, 5, f.Type, "chan *int32");
|
||||
f = styp.Field(1);
|
||||
|
||||
f, present := styp.FieldByName("d");
|
||||
if !present {
|
||||
t.Errorf("FieldByName says present field is absent");
|
||||
}
|
||||
testType(t, 6, f.Type, "float32");
|
||||
|
||||
f, present = styp.FieldByName("absent");
|
||||
if present {
|
||||
t.Errorf("FieldByName says absent field is present");
|
||||
}
|
||||
|
||||
typ = Typeof(([32]int32)(nil));
|
||||
testType(t, 7, typ, "[32]int32");
|
||||
testType(t, 8, typ.(*ArrayType).Elem(), "int32");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue