Golang encoding/gob.Decoder.Decode() function example
package encoding/gob
Decode reads the next value from the input stream and stores it in the data represented by the empty interface value. If e (1st parameter) is nil, the value will be discarded. Otherwise, the value underlying e must be a pointer to the correct type for the next data item received. If the input is at EOF, Decode returns io.EOF and does not modify e.
Golang encoding/gob.Decoder.Decode() 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)
return decoder.Decode(&output) // <-- here
}
Reference :
Advertisement
Something interesting
Tutorials
+9.3k Golang : How to get ECDSA curve and parameters data?
+22.7k Golang : Strings to lowercase and uppercase example
+7.3k Golang : Calculate how many weeks left to go in a given year
+4.7k Javascript : Access JSON data example
+35.5k Golang : Smarter Error Handling with strings.Contains()
+6.9k Golang : How to solve "too many .rsrc sections" error?
+6k Linux/MacOSX : Search for files by filename and extension with find command
+13.7k Golang : Image to ASCII art example
+28k Golang : Move file to another directory
+17.3k Golang : How to tell if a file is compressed either gzip or zip ?
+8.6k Golang : Another camera capture GUI application with GTK and OpenCV
+5.5k Clean up Visual Studio For Mac installation failed disk full problem