mirror of
https://github.com/adnanh/webhook.git
synced 2025-10-04 13:41:03 +00:00
* Update go-chi dependency to v5 * Update gofrs/uuid dependency to v5 * Update gorilla/mux dependency to v1.8.1 * Update go-humanize dependency to v1.0.1 * Update mxj dependency to v2.7.0 * Update fsnotify dependency to v1.7.0 * Update Go versions in GH build workflow * Update gopkg.in/yaml.v2 indirect dependency to v2.4.0 * Bump GH actions
35 lines
837 B
Go
35 lines
837 B
Go
// gob.go - Encode/Decode a Map into a gob object.
|
|
|
|
package mxj
|
|
|
|
import (
|
|
"bytes"
|
|
"encoding/gob"
|
|
)
|
|
|
|
// NewMapGob returns a Map value for a gob object that has been
|
|
// encoded from a map[string]interface{} (or compatible type) value.
|
|
// It is intended to provide symmetric handling of Maps that have
|
|
// been encoded using mv.Gob.
|
|
func NewMapGob(gobj []byte) (Map, error) {
|
|
m := make(map[string]interface{}, 0)
|
|
if len(gobj) == 0 {
|
|
return m, nil
|
|
}
|
|
r := bytes.NewReader(gobj)
|
|
dec := gob.NewDecoder(r)
|
|
if err := dec.Decode(&m); err != nil {
|
|
return m, err
|
|
}
|
|
return m, nil
|
|
}
|
|
|
|
// Gob returns a gob-encoded value for the Map 'mv'.
|
|
func (mv Map) Gob() ([]byte, error) {
|
|
var buf bytes.Buffer
|
|
enc := gob.NewEncoder(&buf)
|
|
if err := enc.Encode(map[string]interface{}(mv)); err != nil {
|
|
return nil, err
|
|
}
|
|
return buf.Bytes(), nil
|
|
}
|