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{})
| 232 | // package works. Because of this, you should only use this function |
| 233 | // to encode simple types. |
| 234 | func (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 |