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: should ignore unexported fields #2517

Closed
gopherbot opened this issue Dec 2, 2011 · 2 comments
Closed

encoding/gob: should ignore unexported fields #2517

gopherbot opened this issue Dec 2, 2011 · 2 comments
Assignees

Comments

@gopherbot
Copy link

@gopherbot gopherbot commented Dec 2, 2011

by runningwild:

gob should be able to encode types that contain chans and functions, so long as those
fields are not exported.

-------------

package main

import (
  "encoding/gob"
  "bytes"
)

type Foo struct {
  A int
  b chan int
}

func main() {
  f := Foo{}
  var stream bytes.Buffer
  enc := gob.NewEncoder(&stream)
  err := enc.Encode(f)
  if err != nil {
    println(err.Error())
    return
  }
}

-------------

gob fails to encode in the above program with the error "gob: can't encode type
chan int".  Because gob isn't going to encode the field b anyway, because it is
unexported, the fact that it is a channel should not cause an error.

Compiler: 6g
OS: OSX 10.6.8
hg id: fb1cf5563774 tip
@rsc
Copy link
Contributor

@rsc rsc commented Dec 2, 2011

Comment 1:

Owner changed to @robpike.

Status changed to Accepted.

@robpike
Copy link
Contributor

@robpike robpike commented Dec 2, 2011

Comment 2:

This issue was closed by revision 30775f6.

Status changed to Fixed.

@gopherbot gopherbot added fixed labels Dec 2, 2011
@mikioh mikioh changed the title gob should ignore unexported fields encoding/gob: should ignore unexported fields Feb 26, 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.
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.