From aa00da5a4578bf7a5f437e6862bd444a04cb1449 Mon Sep 17 00:00:00 2001 From: Mateusz Poliwczak Date: Thu, 19 Sep 2024 11:50:34 +0200 Subject: [PATCH] style update --- src/sync/oncefunc.go | 4 ++-- src/sync/oncefunc_test.go | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/sync/oncefunc.go b/src/sync/oncefunc.go index 52daeeb767a..b7cf96c88f6 100644 --- a/src/sync/oncefunc.go +++ b/src/sync/oncefunc.go @@ -49,7 +49,7 @@ func OnceValue[T any](f func() T) func() T { ) g := func() { defer func() { - f = nil // Do not keep f alive after invoking it. + f = nil p = recover() if !valid { panic(p) @@ -81,7 +81,7 @@ func OnceValues[T1, T2 any](f func() (T1, T2)) func() (T1, T2) { ) g := func() { defer func() { - f = nil // Do not keep f alive after invoking it. + f = nil p = recover() if !valid { panic(p) diff --git a/src/sync/oncefunc_test.go b/src/sync/oncefunc_test.go index da1094f3330..05dd65a3114 100644 --- a/src/sync/oncefunc_test.go +++ b/src/sync/oncefunc_test.go @@ -198,7 +198,6 @@ func TestOnceXGC(t *testing.T) { f := sync.OnceValues(func() (any, any) { buf[0] = 1; return nil, nil }) return func() { f() } }, - "OnceFunc panic": func(buf []byte) func() { return sync.OnceFunc(func() { buf[0] = 1; panic("test panic") }) },