Skip to content

Instantly share code, notes, and snippets.

@polynomialspace
Created February 26, 2021 11:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save polynomialspace/b2dede76a92bfd8374d01ac0d62f5eb1 to your computer and use it in GitHub Desktop.
Save polynomialspace/b2dede76a92bfd8374d01ac0d62f5eb1 to your computer and use it in GitHub Desktop.
similar marshal/unmarshal functions as other encoders for gob
func gobMarshal(v interface{}) ([]byte, error) {
var buf bytes.Buffer
enc := gob.NewEncoder(&buf)
err := enc.Encode(v)
return buf.Bytes(), err
}
func gobUnmarshal(data []byte, v interface{}) error {
dec := gob.NewDecoder(bytes.NewReader(data))
return dec.Decode(v)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment