MCPcopy Create free account
hub / github.com/beeker1121/goque / UpdateObject

Method UpdateObject

stack.go:234–241  ·  view source on GitHub ↗

UpdateObject is a helper function for Update that accepts any value type, which is then encoded into a byte slice using encoding/gob. Objects containing pointers with zero values will decode to nil when using this function. This is due to how the encoding/gob package works. Because of this, you sho

(id uint64, newValue interface{})

Source from the content-addressed store, hash-verified

232// package works. Because of this, you should only use this function
233// to encode simple types.
234func (s *Stack) UpdateObject(id uint64, newValue interface{}) (*Item, error) {
235 var buffer bytes.Buffer
236 enc := gob.NewEncoder(&buffer)
237 if err := enc.Encode(newValue); err != nil {
238 return nil, err
239 }
240 return s.Update(id, buffer.Bytes())
241}
242
243// UpdateObjectAsJSON is a helper function for Update that accepts
244// any value type, which is then encoded into a JSON byte slice using

Callers 4

TestStackUpdateObjectFunction · 0.45
TestQueueUpdateObjectFunction · 0.45

Calls 1

UpdateMethod · 0.95

Tested by 4

TestStackUpdateObjectFunction · 0.36
TestQueueUpdateObjectFunction · 0.36