From: Tim King Date: Wed, 27 Nov 2024 21:13:07 +0000 (-0800) Subject: doc/next: document copylock changes X-Git-Tag: go1.24rc1~63 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=b7e450bf27f28f60e574ac4ee4db165f771669a6;p=gostls13.git doc/next: document copylock changes Fixes #66387 Change-Id: Ida9381d1ea83bcceaba460014fac3d0c13ccdbff Reviewed-on: https://go-review.googlesource.com/c/go/+/632315 LUCI-TryBot-Result: Go LUCI Commit-Queue: Tim King Reviewed-by: Alan Donovan --- diff --git a/doc/next/3-tools.md b/doc/next/3-tools.md index 144ac5e67b..33a4e682dc 100644 --- a/doc/next/3-tools.md +++ b/doc/next/3-tools.md @@ -49,6 +49,15 @@ with no other arguments. Such calls are nearly always a mistake as the value of `s` may contain the `%` symbol; use `fmt.Print` instead. See [#60529](/issue/60529). + +The existing `copylock` analyzer now reports a diagnostic when a +variable declared in a 3-clause "for" loop such as +`for i := iter(); done(i); i = next(i) { ... }` contains a `sync.Locker`, +such as a `sync.Mutex`. [Go 1.22](/doc/go1.22#language) changed the behavior +of these loops to create a new variable for each iteration, copying the +value from the previous iteration; this copy operation is not safe for locks. +See [#66387](/issue/66387). + ### GOCACHEPROG