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
+8k Golang : Handle Palindrome string with case sensitivity and unicode
+6.1k Golang : Get missing location after unmarshal binary and gob decode time.
+16.9k Golang : Get the IPv4 and IPv6 addresses for a specific network interface
+22.1k Golang : Repeat a character by multiple of x factor
+7.9k Golang Hello World Example
+25.7k Golang : How to write CSV data to file
+29.9k Golang : How to get HTTP request header information?
+5.8k Cash Flow : 50 days to pay your credit card debt
+5k Golang : Display packages names during compilation
+20.7k Android Studio : AlertDialog and EditText to get user string input example
+32.7k Golang : Regular Expression for alphanumeric and underscore
+12.9k Python : Convert IPv6 address to decimal and back to IPv6