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 : Error reading timestamp with GORM or SQL driver
+6.4k PHP : Proper way to get UTF-8 character or string length
+6.9k Golang : How to setup a disk space used monitoring service with Telegram bot
+9.7k Golang : Eroding and dilating image with OpenCV example
+5.4k How to check with curl if my website or the asset is gzipped ?
+8.8k Yum Error: no such table: packages
+19k Golang : Padding data for encryption and un-padding data for decryption
+24.5k Golang : GORM read from database example
+37.7k Golang : Comparing date or timestamp
+11.4k Golang : Concatenate (combine) buffer data example
+31.9k Golang : Convert an image file to []byte
+6.7k Golang : Humanize and Titleize functions