-
Notifications
You must be signed in to change notification settings - Fork 18.3k
Closed
Labels
Milestone
Description
http://play.golang.org/p/cNlOycuLzl is this: package main import ( "bytes" "encoding/gob" "time" ) type Update struct { Time time.Time // *** Note1 : Works if change from time.Time -> int ***// } type Time struct { T *time.Time } type PC struct { Id int64 Update []Update // *** Note2 : Works if comment out one of Update or LastUpdate ***// LastUpdate Time } func main() { buf := new(bytes.Buffer) enc := gob.NewEncoder(buf) var err error if err = enc.Encode(PC{}); err != nil { println("A", err.Error()) return } dec := gob.NewDecoder(bytes.NewBuffer(buf.Bytes())) if err = dec.Decode(new(PC)); err != nil { println("B", err.Error()) return } } It prints "B extra data in buffer. Removing either of the time.Time values from the struct or replacing them with ints clears up the error. Something is awry with gots and time.