https://go.dev/issue/57969

- sean

On Sat, Mar 25, 2023, 06:45 Amnon <amno...@gmail.com> wrote:

> Hi Gophers,
> Last year there was a discussion about removing one of the
> more common gotchas in Go.
>
> To quote from the discussion:
>
> the problem is that loops like this one don’t do what they look like they
> do:
>
> var all []*Item
> for _, item := range items { all = append(all, &item) }
>
> That is, this code has a bug. After this loop executes, all contains
> len(items) identical pointers, each pointing at the same Item, holding
> the last value iterated over. This happens because the item variable is
> per-loop, not per-iteration: &item is the same on every iteration, and
> item is overwritten on each iteration.
> https://github.com/golang/go/discussions/56010
>
> What was the resolution of this discussion?
> Was the proposed change accepted?
> Will it be released in Go 1.21 or 1.22?
>
> It is hard to figure this out from the discussion. There are hundreds of
> comments,
> but there is no clear marking of the resolution (apart from the discussion
> now being closed) either at the top of bottom of the discussion.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/5d88208e-fbbf-44d5-b693-50deff176fedn%40googlegroups.com
> <https://groups.google.com/d/msgid/golang-nuts/5d88208e-fbbf-44d5-b693-50deff176fedn%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAGabyPq0Ffzw2O1wmQ4Qd-uoFrzyUhUuhqSYA-Na1vSbkHo4nQ%40mail.gmail.com.

Reply via email to