// setField implements x.name = y.
515512
func setField(fr *Frame, x Value, name string, y Value) error {
	if x, ok := x.(HasSetField); ok {
		err := x.SetField(name, y)
		return err
	}
	return fmt.Errorf("can't assign to .%s field of %s", name, x.Type())
}
784253
func SetNestedField(obj map[string]interface{}, value interface{}, fields ...string) error {
	return setNestedFieldNoCopy(obj, runtime.DeepCopyJSONValue(value), fields...)
}
208822
func (s *IntOptions) SetSourceField(v string) *IntOptions {
	s.SourceField = &v
	return s
}
705161
func (s *Input) SetName(v string) *Input {
	s.Name = &v
	return s
}
428781
func (s *DeleteResolverInput) SetFieldName(v string) *DeleteResolverInput {
	s.FieldName = &v
	return s
}
1082992
func (logger *Logger) SetFields(fields map[string]interface{}) {
	for k, v := range fields {
		logger.Fields[k] = v
	}
}
392037
func SetField(obj interface{}, name string, value interface{}) error {
	structValue := reflect.ValueOf(obj).Elem()
	structFieldValue := structValue.FieldByName(name)

	if !structFieldValue.IsValid() {
		return fmt.Errorf("No such field: %s in obj", name)
	}

	if !structFieldValue.CanSet() {
		return fmt.Errorf("Cannot set %s field value", name)
	}

	structFieldType := structFieldValue.Type()
	val := reflect.ValueOf(value)
	if structFieldType != val.Type() {
		invalidTypeError := errors.New("Provided value type didn't match obj field type")
		return invalidTypeError
	}

	structFieldValue.Set(val)
	return nil
}
747833
func (s *SortCriterion) SetField(v string) *SortCriterion {
	s.Field = &v
	return s
}
632071
func (f *Field) SetParam(key string, value interface{}) FieldInterface {
	f.params[key] = value
	return f
}
1168267
func (s *DefineIndexFieldInput) SetIndexField(v *IndexField) *DefineIndexFieldInput {
	s.IndexField = v
	return s
}
1263783
func (m *Meta) setField(k string, v starlark.Value) (err error) {
	ptr := m.fieldsMap()[k]
	if ptr == nil {
		return fmt.Errorf("set_meta: no such meta key %q", k)
	}

	// On success, mark the field as modified.
	defer func() {
		if err == nil {
			m.touch(ptr)
		}
	}()

	switch ptr := ptr.(type) {
	case *string:
		if str, ok := v.(starlark.String); ok {
			*ptr = str.GoString()
			return nil
		}
		return fmt.Errorf("set_meta: got %s, expecting string", v.Type())

	case *bool:
		if b, ok := v.(starlark.Bool); ok {
			*ptr = bool(b)
			return nil
		}
		return fmt.Errorf("set_meta: got %s, expecting bool", v.Type())

	case *[]string:
		if iterable, ok := v.(starlark.Iterable); ok {
			iter := iterable.Iterate()
			defer iter.Done()

			var vals []string
			for x := starlark.Value(nil); iter.Next(&x); {
				if str, ok := x.(starlark.String); ok {
					vals = append(vals, str.GoString())
				} else {
					return fmt.Errorf("set_meta: got %s, expecting string", x.Type())
				}
			}

			*ptr = vals
			return nil
		}
		return fmt.Errorf("set_meta: got %s, expecting an iterable", v.Type())

	default:
		panic("impossible")
	}
}
649866
func (s *DocumentSuggesterOptions) SetSourceField(v string) *DocumentSuggesterOptions {
	s.SourceField = &v
	return s
}
647936
func (s *LiteralOptions) SetSourceField(v string) *LiteralOptions {
	s.SourceField = &v
	return s
}
807993
func (entry *Entry) SetField(name string, value string) {
	entry.fields[name] = value
}
5728
func (m *Message) SetField(name string, val starlark.Value) error {
	fd, ok := m.typ.fields[name]
	if !ok {
		return fmt.Errorf("proto message %q has no field %q", m.Type(), name)
	}

	// Setting a field to None removes it completely.
	if val == starlark.None {
		if err := m.checkMutable(); err != nil {
			return err
		}
		delete(m.fields, name)
		return nil
	}

	// If assigning to a messaged-valued field (singular or repeated), recognize
	// dicts and Nones and use them to instantiate values (perhaps empty) of the
	// corresponding proto type. This allows to construct deeply nested protobuf
	// messages just by using lists, dicts and primitive values. Python does this
	// too.
	val, err := maybeMakeMessages(fd.typ, val)
	if err != nil {
		return fmt.Errorf("when constructing %q in proto %q - %s", name, m.Type(), err)
	}

	// Do a light type check. It doesn't "recurse" into lists or tuples. So it is
	// still possible to assign e.g. a list of strings to a "repeated int64"
	// field. This will be discovered later in ToProto when trying to construct
	// a proto message from Starlark values.
	if err := checkAssignable(fd.typ, val); err != nil {
		return fmt.Errorf("can't assign value of type %q to field %q in proto %q - %s", val.Type(), name, m.Type(), err)
	}
	if err := m.checkMutable(); err != nil {
		return err
	}
	m.fields[name] = val

	// onChanged hooks is used by oneof's to clear alternatives that weren't
	// picked.
	if fd.onChanged != nil {
		fd.onChanged(m.fields)
	}

	return nil
}
73571
func (f *Field) Field(name string) *Field {
	field, ok := f.FieldOk(name)
	if !ok {
		panic("field not found")
	}

	return field
}
1222294
func (s *JobManifestSpec) SetFields(v []*string) *JobManifestSpec {
	s.Fields = v
	return s
}