Original post

hello, I found the code in the std source code;
I am confused by the runtime.KeepAlive(x) call;
Can anyone tell me why it needed here;
As far as I know, verifyGCInfo refernces the x by &x; so it’s seems unnecessarily here.

var x string
verifyGCInfo(t, “stack string”, &x, infoString)
runtime.KeepAlive(x)

func verifyGCInfo(t *testing.T, name string, p interface{}, mask0 []byte) {
mask := runtime.GCMask§
if !bytes.Equal(mask, mask0) {
t.Errorf(“bad GC program for %v:nwant %+vngot %+v”, name, mask0, mask)
return
}
}