Search code examples
gogob

gob not decoding as expected


Here is my playground where I am trying to serialize a list of structures and read back from the file.

https://play.golang.org/p/8x0uciOd1Sq

I was expecting the object to be decoded successfully. What am I doing wrong?


Solution

  • Export the field names by capitalizing the first letter.

    type REntry struct {
          Key         string
          Value       []string
     }
    

    The gob package and other similar packages ignore unexported fields.