Golang encoding/gob.NewDecoder() function example
package encoding/gob
NewDecoder returns a new decoder that reads from the io.Reader. If r (1st parameter) does not also implement io.ByteReader, it will be wrapped in a bufio.Reader.
Golang encoding/gob.NewDecoder() function usage example
type Item struct {
Data interface{}
Name string
}
func decode_gob(data []byte, output *Item) error {
buffer := bytes.NewBuffer(data)
decoder := gob.NewDecoder(buffer) // <-- here
return decoder.Decode(&output)
}
Reference :
Advertisement
Something interesting
Tutorials
+7.8k Golang : Scan files for certain pattern and rename part of the files
+7.6k Golang : Set horizontal, vertical scroll bars policies and disable interaction on Qt image
+12.8k Golang : http.Get example
+8.3k Golang : Check if integer is power of four example
+5.7k Golang : Struct field tags and what is their purpose?
+12.3k Golang : Validate email address
+11.7k Golang : Calculations using complex numbers example
+18.5k Golang : Send email with attachment
+3.7k Golang : Switch Redis database redis.NewClient
+14.6k Golang : GUI with Qt and OpenCV to capture image from camera
+12.1k Golang : convert(cast) string to integer value
+12.2k Golang : Simple client-server HMAC authentication without SSL example