0

I use the below code to create a gob file which go successfully executes

var METADATA = []interface{}{
     map[string]interface{}{...},
     map[string]interface{}{...},
     ...
} 

gob.Register(map[string]interface{}{})
gob.Register([]interface{}{})
file, err := os.Create("./thrift_metadata.gob")
if err != nil {
    return err
}
encoder := gob.NewEncoder(file)
err = decoder.Decode(object)

Below is the decoder compiled from a completely different codebase and debug binary, which fails.

    gobPath := path.Join(currentWorkingDirectory, "./thrift_metadata.gob")
    file, err := os.Open(gobPath)
    if err != nil {
        panic(err)
    }
    gob.Register(map[string]interface{}{})
    gob.Register([]interface{}{})
    decoder := gob.NewDecoder(file)
    err = decoder.Decode(object)

The decoding code fails with the following error:

gob: decoding into local type *[]map[string]interface {}, received remote type 

Anyone know how to resolve this issue?

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
Brian Yeh
  • 3,119
  • 3
  • 26
  • 40
  • Please provide a minimal verifiable example that others can run to help debug the issue. Right now your question doesn't have enough information to get you help. See https://stackoverflow.com/help/mcve – Eli Bendersky Jan 23 '19 at 14:16
  • This is a bad question. However I already solved the issue using another work around that avoided using gobs. I am voting to close. – Brian Yeh Jan 24 '19 at 03:17

0 Answers0