encoding/gob: no way to skip marshalling exported struct field, docs unclear that a struct must have minimum one exported field #19969
Labels
Documentation
Issues describing a change to documentation.
FrozenDueToAge
NeedsDecision
Feedback is required from experts, contributors, and/or the community before a change can be made.
Milestone
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go1.8
What operating system and processor architecture are you using (
go env
)?go env
set GOARCH=amd64
set GOBIN=
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\home\auld\godev
set GORACE=
set GOROOT=C:\Go
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Use
rs\auld\AppData\Local\Temp\go-build485133467=/tmp/go-build -gno-record-gcc
-switches
set CXX=g++
set CGO_ENABLED=1
set PKG_CONFIG=pkg-config
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
What did you do?
The program should transmit its User struct and receive it via a fake network and print the transferred data. Line 15-17 of the below play area program contains three cases. The third case (3) works correctly and transfers all the data as expected. Case two (2) also transfers all the data but based on the documentation I believe only the values associated with exported field should be transferred. Case one (1) does not transfer any data, not even the exported fields from User.
I believe both case 1 and 2 represent bugs.
If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.
https://play.golang.org/p/Y7ZPpq9-8v
What did you expect to see?
Case 1: &{Donald DuckPass []}
Case 2: &{Donald DuckPass [{ 2} { 1}]}
Case 3: &{Donald DuckPass [{1 2} {2 1}]}
What did you see instead?
Case 1: 2009/11/10 23:00:00 encode error:gob: type main.j has no exported fields
Case 2: &{Donald DuckPass [{1 2} {2 1}]}
Case 3: &{Donald DuckPass [{1 2} {2 1}]}
The text was updated successfully, but these errors were encountered: