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
+10.2k Golang : Check a web page existence with HEAD request example
+11.6k CodeIgniter : Import Linkedin data
+6.9k Default cipher that OpenSSL used to encrypt a PEM file
+9.4k Golang : Launch Mac OS X Preview (or other OS) application from your program example
+9.2k Golang : io.Reader causing panic: runtime error: invalid memory address or nil pointer dereference
+12.2k Golang : Perform sanity checks on filename example
+13.6k Golang : Count number of runes in string
+46.3k Golang : Read tab delimited file with encoding/csv package
+5.3k Python : Create Whois client or function example
+17.8k How to enable MariaDB/MySQL logs ?
+34.8k Golang : How to stream file to client(browser) or write to http.ResponseWriter?