mirror of
https://github.com/golang/go
synced 2024-11-21 17:04:42 -07:00
style update
This commit is contained in:
parent
7e202ad83f
commit
aa00da5a45
@ -49,7 +49,7 @@ func OnceValue[T any](f func() T) func() T {
|
|||||||
)
|
)
|
||||||
g := func() {
|
g := func() {
|
||||||
defer func() {
|
defer func() {
|
||||||
f = nil // Do not keep f alive after invoking it.
|
f = nil
|
||||||
p = recover()
|
p = recover()
|
||||||
if !valid {
|
if !valid {
|
||||||
panic(p)
|
panic(p)
|
||||||
@ -81,7 +81,7 @@ func OnceValues[T1, T2 any](f func() (T1, T2)) func() (T1, T2) {
|
|||||||
)
|
)
|
||||||
g := func() {
|
g := func() {
|
||||||
defer func() {
|
defer func() {
|
||||||
f = nil // Do not keep f alive after invoking it.
|
f = nil
|
||||||
p = recover()
|
p = recover()
|
||||||
if !valid {
|
if !valid {
|
||||||
panic(p)
|
panic(p)
|
||||||
|
@ -198,7 +198,6 @@ func TestOnceXGC(t *testing.T) {
|
|||||||
f := sync.OnceValues(func() (any, any) { buf[0] = 1; return nil, nil })
|
f := sync.OnceValues(func() (any, any) { buf[0] = 1; return nil, nil })
|
||||||
return func() { f() }
|
return func() { f() }
|
||||||
},
|
},
|
||||||
|
|
||||||
"OnceFunc panic": func(buf []byte) func() {
|
"OnceFunc panic": func(buf []byte) func() {
|
||||||
return sync.OnceFunc(func() { buf[0] = 1; panic("test panic") })
|
return sync.OnceFunc(func() { buf[0] = 1; panic("test panic") })
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user