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
+4.4k Golang : Valued expressions and functions example
+19.3k Golang : Get host name or domain name from IP address
+12.1k Golang : Decompress zlib file example
+6.9k Golang : Calculate BMI and risk category
+9k Golang : Build and compile multiple source files
+25.9k Golang : How to read integer value from standard input ?
+28.2k Golang : Connect to database (MySQL/MariaDB) server
+14.2k Elastic Search : Mapping date format and sort by date
+12.7k Android Studio : Highlight ImageButton when pressed on example
+26.4k Golang : Convert(cast) string to uint8 type and back to string
+16.4k Golang : How to implement two-factor authentication?
+29.9k Golang : How to get HTTP request header information?