Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

encoding/gob: isZero called for struct implementing GobEncoder #2577

rsc opened this issue Dec 16, 2011 · 1 comment

encoding/gob: isZero called for struct implementing GobEncoder #2577

rsc opened this issue Dec 16, 2011 · 1 comment


Copy link

@rsc rsc commented Dec 16, 2011

package main

import (

type X struct {
   T time.Time
   S string
   I int

func main() {
   var buffer bytes.Buffer
   encoder := gob.NewEncoder(&buffer)
   x := X{time.Now(), "hello", -55}
   decoder := gob.NewDecoder(&buffer)
   var y X

Reported by Mark Summerfield.

panic: unknown type in isZero time.Time [recovered]  <<<<<
    panic: interface conversion: interface is string, not gob.gobError

goroutine 1 [running]:
encoding/gob.catchError(0xf840022090, 0x216f100)
    /Users/rsc/g/go/src/pkg/encoding/gob/error.go:36 +0x67
----- stack segment boundary -----
encoding/gob.isZero(0x9f208, 0xf84002a7b0, 0x192, 0xf84002a7b0, 0x192, ...)
    /Users/rsc/g/go/src/pkg/encoding/gob/encode.go:487 +0x14d
encoding/gob._func_018(0xf84001b368, 0xf840002510, 0x2ae96, 0xf8400273c0, 0xf84002a120,
    /Users/rsc/g/go/src/pkg/encoding/gob/encode.go:638 +0xcd
encoding/gob.(*Encoder).encodeStruct(0xf840022000, 0xf840022030, 0xf8400024f0,
0xf84002a7b0, 0x93758, ...)
    /Users/rsc/g/go/src/pkg/encoding/gob/encode.go:370 +0xf4
encoding/gob.(*Encoder).encode(0xf840022000, 0xf840022030, 0x93758, 0xf84002a2a0, 0x192,
    /Users/rsc/g/go/src/pkg/encoding/gob/encode.go:713 +0x172
encoding/gob.(*Encoder).EncodeValue(0xf840022000, 0x93758, 0xf84002a2a0, 0x192, 0x0, ...)
    /Users/rsc/g/go/src/pkg/encoding/gob/encoder.go:246 +0x247
encoding/gob.(*Encoder).Encode(0xf840022000, 0x93748, 0xf84002a2a0, 0x114ba8, 0xaaf44,
    /Users/rsc/g/go/src/pkg/encoding/gob/encoder.go:177 +0x50
    /Users/rsc/x.go:21 +0x1ae
Copy link

@robpike robpike commented Dec 16, 2011

Comment 1:

This issue was closed by revision 4fb5f54.

Status changed to Fixed.

@rsc rsc added fixed labels Dec 16, 2011
@mikioh mikioh changed the title gob: isZero called for struct implementing GobEncoder encoding/gob: isZero called for struct implementing GobEncoder Feb 26, 2015
@rsc rsc added this to the Go1 milestone Apr 10, 2015
@rsc rsc removed the priority-go1 label Apr 10, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.