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.9k Golang : Pat multiplexer routing example
+12.9k Golang : Listen and Serve on sub domain example
+9.8k PHP : Get coordinates latitude/longitude from string
+8.4k Golang : Auto-generate reply email with text/template package
+15.2k Golang : How to add color to string?
+8.1k Golang : What fmt.Println() can do and println() cannot do
+6.1k PHP : How to check if an array is empty ?
+13.5k Golang : error parsing regexp: invalid or unsupported Perl syntax
+13.5k Golang : Read from buffered reader until specific number of bytes
+12.6k Golang : Forwarding a local port to a remote server example
+11.2k Golang : Simple image viewer with Go-GTK
+4.8k MariaDB/MySQL : Form select statement or search query with Chinese characters