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

Method PushObject

stack.go:99–107  ·  view source on GitHub ↗

PushObject is a helper function for Push 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 should

(value interface{})

Source from the content-addressed store, hash-verified

97// package works. Because of this, you should only use this function
98// to encode simple types.
99func (s *Stack) PushObject(value interface{}) (*Item, error) {
100 var buffer bytes.Buffer
101 enc := gob.NewEncoder(&buffer)
102 if err := enc.Encode(value); err != nil {
103 return nil, err
104 }
105
106 return s.Push(buffer.Bytes())
107}
108
109// PushObjectAsJSON is a helper function for Push that accepts any
110// value type, which is then encoded into a JSON byte slice using

Callers 1

TestStackUpdateObjectFunction · 0.80

Calls 1

PushMethod · 0.95

Tested by 1

TestStackUpdateObjectFunction · 0.64