summaryrefslogtreecommitdiffstats
path: root/src/encoding
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-16 19:27:10 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-16 19:27:10 +0000
commit32c8b04ddb6829a3f5f7267a666b4caa3cf38a1f (patch)
tree6e5b1b98afaeadd19ba7fd4b710f71cbf187942e /src/encoding
parentAdding upstream version 1.22.1. (diff)
downloadgolang-1.22-32c8b04ddb6829a3f5f7267a666b4caa3cf38a1f.tar.xz
golang-1.22-32c8b04ddb6829a3f5f7267a666b4caa3cf38a1f.zip
Adding upstream version 1.22.2.upstream/1.22.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--src/encoding/gob/encode.go2
-rw-r--r--src/encoding/gob/type.go15
2 files changed, 14 insertions, 3 deletions
diff --git a/src/encoding/gob/encode.go b/src/encoding/gob/encode.go
index 5f4d253..c83071c 100644
--- a/src/encoding/gob/encode.go
+++ b/src/encoding/gob/encode.go
@@ -601,7 +601,7 @@ func compileEnc(ut *userTypeInfo, building map[*typeInfo]bool) *encEngine {
if ut.externalEnc == 0 && srt.Kind() == reflect.Struct {
for fieldNum, wireFieldNum := 0, 0; fieldNum < srt.NumField(); fieldNum++ {
f := srt.Field(fieldNum)
- if !isSent(&f) {
+ if !isSent(srt, &f) {
continue
}
op, indir := encOpFor(f.Type, seen, building)
diff --git a/src/encoding/gob/type.go b/src/encoding/gob/type.go
index 30d8ca6..3b1dde4 100644
--- a/src/encoding/gob/type.go
+++ b/src/encoding/gob/type.go
@@ -538,7 +538,7 @@ func newTypeObject(name string, ut *userTypeInfo, rt reflect.Type) (gobType, err
idToTypeSlice[st.id()] = st
for i := 0; i < t.NumField(); i++ {
f := t.Field(i)
- if !isSent(&f) {
+ if !isSent(t, &f) {
continue
}
typ := userType(f.Type).base
@@ -576,7 +576,7 @@ func isExported(name string) bool {
// isSent reports whether this struct field is to be transmitted.
// It will be transmitted only if it is exported and not a chan or func field
// or pointer to chan or func.
-func isSent(field *reflect.StructField) bool {
+func isSent(struct_ reflect.Type, field *reflect.StructField) bool {
if !isExported(field.Name) {
return false
}
@@ -589,6 +589,17 @@ func isSent(field *reflect.StructField) bool {
if typ.Kind() == reflect.Chan || typ.Kind() == reflect.Func {
return false
}
+
+ // Special case for Go 1.22: the x509.Certificate.Policies
+ // field is unencodable but also unused by default.
+ // Ignore it, so that x509.Certificate continues to be encodeable.
+ // Go 1.23 will add the right methods so that gob can
+ // handle the Policies field, and then we can remove this check.
+ // See go.dev/issue/65633.
+ if field.Name == "Policies" && struct_.PkgPath() == "crypto/x509" && struct_.Name() == "Certificate" {
+ return false
+ }
+
return true
}