MCPcopy Create free account
hub / github.com/google/go-cloud / SetField

Method SetField

docstore/driver/document.go:138–153  ·  view source on GitHub ↗

SetField sets the field to value in the document.

(field string, value any)

Source from the content-addressed store, hash-verified

136
137// SetField sets the field to value in the document.
138func (d Document) SetField(field string, value any) error {
139 if d.m != nil {
140 d.m[field] = value
141 return nil
142 }
143 v, err := d.structField(field)
144 if err != nil {
145 return err
146 }
147 if !v.CanSet() {
148 return gcerr.Newf(gcerr.InvalidArgument, nil, "cannot set field %s in struct of type %s: not addressable",
149 field, d.s.Type())
150 }
151 v.Set(reflect.ValueOf(value))
152 return nil
153}
154
155// FieldNames returns names of the top-level fields of d.
156func (d Document) FieldNames() []string {

Callers 8

getDocumentMethod · 0.95
executeActionMethod · 0.80
copyTopLevelFunction · 0.80
onSuccessMethod · 0.80
decodeDocFunction · 0.80
doCommitCallMethod · 0.80
SetMethod · 0.80
bulkWriteMethod · 0.80

Calls 4

structFieldMethod · 0.95
NewfFunction · 0.92
TypeMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected