Golang encoding/gob.NewEncoder() function examples
package encoding/gob
NewEncoder returns a new encoder that will transmit on the io.Writer.
Golang encoding/gob.NewEncoder() function usage examples
Example 1 :
buff := new(bytes.Buffer)
enc := gob.NewEncoder(buff)
Example 2 :
func encode_gob(data interface{}) ([]byte, error) {
buff := bytes.NewBuffer(nil)
enc := gob.NewEncoder(buff)
err := enc.Encode(data)
if err != nil {
return nil, err
}
return buff.Bytes(), err
}
References :
Advertisement
Something interesting
Tutorials
+6.8k Golang : Skip or discard items of non-interest when iterating example
+11.9k Golang : Secure file deletion with wipe example
+11.4k Golang : How to pipe input data to executing child process?
+12.5k Golang : 2 dimensional array example
+19.4k Golang : Check whether a network interface is up on your machine
+32.9k Golang : Regular Expression for alphanumeric and underscore
+29.7k Golang : How to create new XML file ?
+42.2k Golang : How do I convert int to uint8?
+9.9k Golang : Resumable upload to Google Drive(RESTful) example
+22.6k Golang : How to read JPG(JPEG), GIF and PNG files ?
+11.1k Golang : Create S3 bucket with official aws-sdk-go package
+15.9k Golang : Intercept Ctrl-C interrupt or kill signal and determine the signal type