Created
February 26, 2021 11:14
-
-
Save polynomialspace/b2dede76a92bfd8374d01ac0d62f5eb1 to your computer and use it in GitHub Desktop.
similar marshal/unmarshal functions as other encoders for gob
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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