]> Cypherpunks repositories - gostls13.git/commit
encoding/asn1: only omit optional elements matching default value.
authorAdam Langley <agl@golang.org>
Mon, 28 Jul 2014 21:47:37 +0000 (14:47 -0700)
committerAdam Langley <agl@golang.org>
Mon, 28 Jul 2014 21:47:37 +0000 (14:47 -0700)
commit8332112d0a84ec70c9c82402ea796b18b83eb8f4
tree4b376e659c2b7cd247aa381c6d8f6d9a6068f236
parent42d0785bbdfa91102b57359721b60fdf8b87ab63
encoding/asn1: only omit optional elements matching default value.

ASN.1 elements can be optional, and can have a default value.
Traditionally, Go has omitted elements that are optional and that have
the zero value. I believe that's a bug (see [1]).

This change causes an optional element with a default value to only be
omitted when it has that default value. The previous behaviour of
omitting optional, zero elements with no default is retained because
it's used quite a lot and will break things if changed.

[1] https://groups.google.com/d/msg/Golang-nuts/9Ss6o9CW-Yo/KL_V7hFlyOAJ

Fixes #7780.

R=bradfitz

LGTM=bradfitz
R=golang-codereviews, bradfitz, rsc
CC=golang-codereviews, r
https://golang.org/cl/86960045
src/pkg/encoding/asn1/asn1.go
src/pkg/encoding/asn1/marshal.go
src/pkg/encoding/asn1/marshal_test.go