We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
go version
go version go1.10 linux/amd64
yes
go env
GOARCH="amd64" GOBIN="/home/rvolosatovs/.local/bin.go" GOCACHE="/home/rvolosatovs/.local/cache/go-build" GOEXE="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOOS="linux" GOPATH="/home/rvolosatovs" GORACE="" GOROOT="/nix/store/r7p21cmhq0jimq2f8c8y5sm2vqg2ap99-go-1.10/share/go" GOTMPDIR="" GOTOOLDIR="/nix/store/r7p21cmhq0jimq2f8c8y5sm2vqg2ap99-go-1.10/share/go/pkg/tool/linux_amd64" GCCGO="gccgo" CC="gcc" CXX="g++" CGO_ENABLED="1" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build642040554=/tmp/go-build -gno-record-gcc-switches"
https://play.golang.org/p/ycEF5lDyE1p
Relevant part of the code:
for _, a := range [][]byte{ nil, []byte{}, []byte{42}, } { var buf bytes.Buffer gob.NewEncoder(&buf).Encode(a) var b []byte gob.NewDecoder(&buf).Decode(&b) fmt.Println(reflect.DeepEqual(b, a)) }
true true true
true
true false true
false
Hence, zero-length slices are encoded in the same way as nil slices, which makes encoding non-symmetric.
nil
The text was updated successfully, but these errors were encountered:
Gob does not have a concept of nil in its data format, so this is working as designed.
Sorry, something went wrong.
But zero-length slice is not nil, right? https://play.golang.org/p/aBW1WGw8RlV
No branches or pull requests
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?What did you do?
https://play.golang.org/p/ycEF5lDyE1p
Relevant part of the code:
What did you expect to see?
true
true
true
What did you see instead?
true
false
true
Hence, zero-length slices are encoded in the same way as
nil
slices, which makes encoding non-symmetric.The text was updated successfully, but these errors were encountered: