Ok, here's a short Go program that reproduces this issue for me, I put
it in a file called gob_test.go:
package main
import (
"bytes"
"encoding/gob"
"fmt"
)
func init() {
gob.Register(make(map[string]interface{}))
}
func main() {
data := make(map[string]interface{})
subdata := make(map[string]interface{})
subdata["bar"] = "baz"
data["foo"] = subdata
data["test"] = "testing"
fmt.Println("Data before:", data)
buffer := new(bytes.Buffer)
encoder := gob.NewEncoder(buffer);
err := encoder.Encode(data)
if err != nil {
fmt.Println("Unable to serialize data:", err)
return
}
decoder := gob.NewDecoder(buffer)
data = nil
err = decoder.Decode(&data)
if err != nil {
fmt.Println("Unable to deserialize data:", err)
}
fmt.Println("Data after:", data)
}
I add the bin path of the go tools from the go1beta2 appengine
distribution to my path and build and run a number of times:
FrancisMBA:server francisli$ 6g gob_test.go
FrancisMBA:server francisli$ 6l gob_test.6
FrancisMBA:server francisli$ ./6.out
Data before: map[foo:map[bar:baz] test:testing]
Unable to deserialize data: gob: name not registered for interface: "ar
\x06string\f\x05\x00\x03baz\x04test\x06string\f\t\x00\atesting
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Data after: map[foo:map[]]
FrancisMBA:server francisli$ ./6.out
Data before: map[foo:map[bar:baz] test:testing]
Data after: map[foo:map[] test:testing]
FrancisMBA:server francisli$ ./6.out
Data before: map[foo:map[bar:baz] test:testing]
Data after: map[foo:map[] test:testing]
FrancisMBA:server francisli$ ./6.out
Data before: map[foo:map[bar:baz] test:testing]
Data after: map[test:testing foo:map[]]
FrancisMBA:server francisli$ ./6.out
Data before: map[foo:map[bar:baz] test:testing]
Unable to deserialize data: gob: name not registered for interface: "ar
\x06string\f\x05\x00\x03baz\x04test\x06string\f\t\x00\atesting
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Data after: map[foo:map[]]
FrancisMBA:server francisli$
Before I file a bug with this, is there something I'm missing or doing
horribly wrong? I'm on Mac OS X 10.7.2, on a latest generation MacBook
Air (Core i5), running the go1beta2 tools from the darwin_amd64
distribution...
Francis
On Feb 14, 6:27 pm, David Symonds <
dsymo...@golang.org> wrote: