newm := newmap.Interface().(map[string]int)
if len(newm) != len(m) {
- t.Errorf("length after copy: newm=%d, m=%d", newm, m)
+ t.Errorf("length after copy: newm=%d, m=%d", len(newm), len(m))
}
for k, v := range newm {
}
v := ValueOf(S{})
if allocs := testing.AllocsPerRun(100, func() { v.Interface() }); allocs > 0 {
- t.Errorf("allocs:", allocs)
+ t.Error("allocs:", allocs)
}
}
}
v := ValueOf(int64(0))
if allocs := testing.AllocsPerRun(100, func() { v.Interface() }); allocs > 0 {
- t.Errorf("allocs:", allocs)
+ t.Error("allocs:", allocs)
}
}
// 1 0
// 3.14 2.72
}
+
+func ExampleStructTag() {
+ type S struct {
+ F string `species:"gopher" color:"blue"`
+ }
+
+ s := S{}
+ st := reflect.TypeOf(s)
+ field := st.Field(0)
+ fmt.Println(field.Tag.Get("color"), field.Tag.Get("species"))
+
+ // Output:
+ // blue gopher
+}