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
+21.2k Golang : How to get time zone and load different time zone?
+5.3k Swift : Convert string array to array example
+6.1k Golang : Missing Subversion command
+6.6k Golang : Embedded or data bundling example
+13.1k Golang : Handle or parse date string with Z suffix(RFC3339) example
+17.4k Golang : Check if IP address is version 4 or 6
+6.5k Golang : Map within a map example
+13.9k Golang : How to determine if a year is leap year?
+18.6k Golang : Get download file size
+10.9k Golang : Get UDP client IP address and differentiate clients by port number
+9.1k Golang : How to capture return values from goroutines?
+14.6k Golang : How to get URL port?