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.7k Golang : Interfacing with PayPal's IPN(Instant Payment Notification) example
+5.3k Golang : Get FX sentiment from website example
+43.5k Golang : Get hardware information such as disk, memory and CPU usage
+13.6k Golang : Qt progress dialog example
+7.7k Golang : Command line ticker to show work in progress
+7.1k Golang : A simple forex opportunities scanner
+10.6k Golang : Simple File Server
+5.4k Golang : What is StructTag and how to get StructTag's value?
+31.5k Golang : Example for ECDSA(Elliptic Curve Digital Signature Algorithm) package functions
+9.4k Golang : Play .WAV file from command line
+7.2k Golang : Null and nil value
+28.6k Golang : Read, Write(Create) and Delete Cookie example