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
+29.3k Golang : Save map/struct to JSON or XML file
+20.8k Golang : Underscore or snake_case to camel case example
+8.9k Golang : Sort lines of text example
+9.1k Golang : Simple histogram example
+12k Golang : Clean formatting/indenting or pretty print JSON result
+8.6k Golang : Convert(cast) []byte to io.Reader type
+11.6k Android Studio : Create custom icons for your application example
+5.9k Facebook : How to force facebook to scrape latest URL link data?
+5.2k Golang : Convert lines of string into list for delete and insert operation
+13.1k Golang : Convert(cast) uintptr to string example
+5.2k Golang : Customize scanner.Scanner to treat dash as part of identifier
+13.3k Golang : Linear algebra and matrix calculation example