MCPcopy Create free account
hub / github.com/cortexlabs/cortex / setFirstField

Function setFirstField

pkg/lib/configreader/reader.go:1172–1181  ·  view source on GitHub ↗

destStruct must be a pointer to a struct

(val interface{}, destStruct interface{})

Source from the content-addressed store, hash-verified

1170
1171// destStruct must be a pointer to a struct
1172func setFirstField(val interface{}, destStruct interface{}) error {
1173 v := reflect.ValueOf(destStruct).Elem().FieldByIndex([]int{0})
1174 if !v.IsValid() || !v.CanSet() {
1175 debug.Ppg(val)
1176 debug.Ppg(destStruct)
1177 return errors.Wrap(ErrorCannotSetStructField(), "first field")
1178 }
1179 v.Set(reflect.ValueOf(val))
1180 return nil
1181}
1182
1183// destStruct must be a pointer to a struct
1184func setFieldNil(destStruct interface{}, fieldName string) error {

Callers

nothing calls this directly

Calls 4

PpgFunction · 0.92
WrapFunction · 0.92
SetMethod · 0.80

Tested by

no test coverage detected