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: errors are inconsistent across runs #3723

Closed
remyoudompheng opened this issue Jun 11, 2012 · 3 comments
Closed

encoding/gob: errors are inconsistent across runs #3723

remyoudompheng opened this issue Jun 11, 2012 · 3 comments
Assignees

Comments

@remyoudompheng
Copy link
Contributor

@remyoudompheng remyoudompheng commented Jun 11, 2012

What steps will reproduce the problem?

Compile and run attached code:

package main

import (
    "bytes"
    "encoding/gob"
    "fmt"
)

type Public struct {
    Name string
    S    Secret
}

type Secret struct{ a, b int }

func main() {
    buf :=  new(bytes.Buffer)
    enc := gob.NewEncoder(buf)
    x := Public{Name: "name", S: Secret{1, 2}}
    err := enc.Encode(x)
    fmt.Println(err)

    buf.Reset()
    enc = gob.NewEncoder(buf)
    err = enc.Encode(x)
    fmt.Println(err)

    var y Public
    dec := gob.NewDecoder(buf)
    err = dec.Decode(&y)
    fmt.Println(err)
    fmt.Printf("%q\n", y.Name)
}


What is the expected output? What do you see instead?

Expect either:

gob: type main.Secret has no exported fields
gob: type main.Secret has no exported fields
<some error>
""

or:

<nil>
<nil>
<nil>
"name"

Got:

gob: type main.Secret has no exported fields
<nil>
<nil>
""


Please use labels and text to provide additional information.

Attachments:

  1. gob.go (486 bytes)
@robpike
Copy link
Contributor

@robpike robpike commented Jun 11, 2012

Comment 1:

Labels changed: added priority-soon, packagebug, removed priority-triage.

Owner changed to @robpike.

Status changed to Accepted.

@robpike
Copy link
Contributor

@robpike robpike commented Jun 12, 2012

Comment 2:

Status changed to Started.

@robpike
Copy link
Contributor

@robpike robpike commented Jun 14, 2012

Comment 3:

Status changed to Fixed.

@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.
Projects
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.