github.com/v2pro/plz@v0.0.0-20221028024117-e5f9aec5b631/reflect2/safe_struct.go (about) 1 package reflect2 2 3 type safeStructType struct { 4 safeType 5 } 6 7 func (type2 *safeStructType) FieldByName(name string) StructField { 8 field, found := type2.Type.FieldByName(name) 9 if !found { 10 panic("field " + name + " not found") 11 } 12 return &safeField{StructField: field} 13 }