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
+16.6k Golang : Execute terminal command to remote machine example
+15.8k Golang : Get checkbox or extract multipart form data value example
+5.9k Get website traffic ranking with Similar Web or Alexa
+6.9k Golang : Humanize and Titleize functions
+18.9k Unmarshal/Load CSV record into struct in Go
+5.8k Golang : Struct field tags and what is their purpose?
+22.3k Golang : Match strings by wildcard patterns with filepath.Match() function
+4.9k MariaDB/MySQL : Form select statement or search query with Chinese characters
+5.8k Golang : Detect words using using consecutive letters in a given string
+51.5k Golang : Check if item is in slice/array
+12.3k Golang : convert(cast) string to integer value
+9.1k Golang : Inject/embed Javascript before sending out to browser example