Does gob encoding/decoding do anything ? In the example below , data looks the same before and after decoding. I am confused, please advise
data = "ABC"
buf := new(bytes.Buffer)
//glob encoding
enc := gob.NewEncoder(buf)
enc.Encode(data)
fmt.Println("Encoded:", data) //Encoded: ABC
//glob decoding
d := gob.NewDecoder(buf)
d.Decode(data)
fmt.Println("Decoded: ", data) //Decoded: ABC
Your comparison is wrong - comparing the data being encoded (data) to the result after being decoded (d.Decode(data)), will obviously lead you to the same result (if everything is working as expected).
The encoding itself will be presented in the underline bytes buffer (try to print the buffer itself - fmt.Println(buf.Bytes())).
Read more on the gob package
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With