You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
The text was updated successfully, but these errors were encountered: