Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 11d605d

Browse files
authored
Merge pull request #1323 from Workiva/fixGob
[go1.20] Fixing a encoding/gob override
2 parents 92f71c0 + edeab09 commit 11d605d

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

compiler/natives/src/encoding/gob/gob.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,14 @@ func (x *atomicEncEnginePointer) Store(val *encEngine) { x.v = val }
2626

2727
// temporarily replacement of growSlice[E any] for go1.20 without generics.
2828
func growSlice(v reflect.Value, ps any, length int) {
29-
vps := reflect.ValueOf(ps)
30-
vs := vps.Elem()
31-
zero := reflect.Zero(vs.Elem().Type())
29+
vps := reflect.ValueOf(ps) // *[]E
30+
vs := vps.Elem() // []E
31+
zero := reflect.Zero(vs.Type().Elem())
3232
vs.Set(reflect.Append(vs, zero))
3333
cp := vs.Cap()
3434
if cp > length {
3535
cp = length
3636
}
3737
vs.Set(vs.Slice(0, cp))
3838
v.Set(vs)
39-
vps.Set(vs.Addr())
4039
}

compiler/natives/src/encoding/gob/gob_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,11 @@ func TestTypeRace(t *testing.T) {
105105
// cannot succeed when nosync is used.
106106
t.Skip("using nosync")
107107
}
108+
109+
func TestCountEncodeMallocs(t *testing.T) {
110+
t.Skip("testing.AllocsPerRun not supported in GopherJS")
111+
}
112+
113+
func TestCountDecodeMallocs(t *testing.T) {
114+
t.Skip("testing.AllocsPerRun not supported in GopherJS")
115+
}

0 commit comments

Comments
 (0)