Skip to content

Commit e382bf5

Browse files
committed
unique: use runtime.AddCleanup instead of runtime.SetFinalizer
Replace the usage of runtime.SetFinalizer with runtime.AddCleanup in tests. Updates #70907 Change-Id: I0d91b6af9643bde278215318f6176277373ddd19 Reviewed-on: https://go-review.googlesource.com/c/go/+/649458 Reviewed-by: Michael Knyszek <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent fba83cd commit e382bf5

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/unique/handle_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,12 @@ func checkMapsFor[T comparable](t *testing.T, value T) {
124124
func TestMakeClonesStrings(t *testing.T) {
125125
s := strings.Clone("abcdefghijklmnopqrstuvwxyz") // N.B. Must be big enough to not be tiny-allocated.
126126
ran := make(chan bool)
127-
runtime.SetFinalizer(unsafe.StringData(s), func(_ *byte) {
128-
ran <- true
129-
})
127+
runtime.AddCleanup(unsafe.StringData(s), func(ch chan bool) {
128+
ch <- true
129+
}, ran)
130130
h := Make(s)
131131

132-
// Clean up s (hopefully) and run the finalizer.
132+
// Clean up s (hopefully) and run the cleanup.
133133
runtime.GC()
134134

135135
select {

0 commit comments

Comments
 (0)