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
+7.7k Golang : Gonum standard normal random numbers example
+5.3k Golang : Map within a map example
+10.7k Golang : Clean formatting/indenting or pretty print JSON result
+8.8k Golang : Function wrapper that takes arguments and return result example
+7.9k Golang : Generate EAN barcode
+8.2k Golang : How to control fmt or log print format?
+23.6k Golang : Get current file path of a file or executable
+15.6k Golang : Get own process identifier
+13.9k Golang : How to get Unix file descriptor for console and file
+6k Ubuntu : connect() to unix:/var/run/php5-fpm.sock failed (13: Permission denied) while connecting to upstream
+12.1k Swift : Convert (cast) Int to String ?
+10.7k Golang : md5 hash of a string