@@ -178,25 +178,24 @@ func getFieldByTag(val reflect.Value, tagName string, fieldNames []string) (inte
178178
179179 valType := val .Type ()
180180 for i := 0 ; i < valType .NumField (); i ++ {
181- tagValue := valType .Field (i ).Tag .Get (tagName )
181+ fieldType := valType .Field (i )
182+ tagValue := fieldType .Tag .Get (tagName )
182183
183184 // If it's an embedded field, traverse it.
184- if tagValue == "" && valType . Field ( i ) .Anonymous {
185+ if tagValue == "" && fieldType .Anonymous {
185186 value := val .Field (i )
186- val , err := getFieldByTag (value , tagName , fieldNames )
187- if err == nil {
188- return val , nil
187+ if valI , err := getFieldByTag (value , tagName , fieldNames ); err == nil {
188+ return valI , nil
189189 }
190190 }
191191
192- parts := strings .Split (tagValue , "," )
193- if parts [0 ] == fieldName {
192+ if tagFieldName , _ , _ := strings .Cut (tagValue , "," ); tagFieldName == fieldName {
194193 value := val .Field (i )
195194 if len (rest ) == 0 {
196195 if value .CanInterface () {
197196 return value .Interface (), nil
198197 }
199- return nil , trace . BadParameter ( "field %v is not accessible" , fieldName )
198+ return nil , & notFoundError { fieldNames : fieldNames }
200199 }
201200
202201 return getFieldByTag (value , tagName , rest )
0 commit comments