Golang encoding/gob.Encoder.Encode() function example
package encoding/gob
Encode transmits the data item represented by the empty interface value, guaranteeing that all necessary type information has been transmitted first.
Golang encoding/gob.Encoder.Encode() function usage example
func encode_gob(data interface{}) ([]byte, error) {
buff := bytes.NewBuffer(nil)
enc := gob.NewEncoder(buff)
err := enc.Encode(data) // <----- here
if err != nil {
return nil, err
}
return buff.Bytes(), err
}
References :
http://golang.org/pkg/encoding/gob/#Encoder.Encode
https://www.socketloop.com/references/golang-encoding-gob-newencoder-function-examples
Advertisement
Something interesting
Tutorials
+14.7k Golang : How to determine if user agent is a mobile device example
+9.3k Golang : Gonum standard normal random numbers example
+14.5k Golang : Recombine chunked files example
+5.4k Python : Create Whois client or function example
+16.5k Golang : Find out mime type from bytes in buffer
+12.9k Golang : zlib compress file example
+5.2k Golang : Constant and variable names in native language
+5.9k Golang : ROT32768 (rotate by 0x80) UTF-8 strings example
+5.1k Python : Convert(cast) bytes to string example
+13.3k Golang : Convert(cast) int to int64
+9.4k Golang : does not implement flag.Value (missing Set method)
+11.8k Golang : Simple file scaning and remove virus example