Why not something simple like: https://play.golang.org/p/iAlflMUdEA
On Monday, November 20, 2017 at 9:48:31 AM UTC-7, Trig wrote:
>
> for i, user := range myList {
> if user.Disabled {
> myList = append(myList[:i], myList[i + 1:]...) // remove user from
> return list
> }
> }
>
>
> Is using
You need to swap elements if you want to remove them from list while
iterating it. There are two ways to do this:
First: iterate backward. This will however, will change the order of
unremoved elements.
Second: iterate forward, and will preserve the order of the unremoved
elements.
https://pl
I tend to be quite careful around removing items from an array/slice/list
and not just in Go.
Deletion of items is probably the most mutable thing you can do to a list -
if the list is shared between goroutines, it could really mess things up.
Rather than delete, I'd suggest a mark and copy appr
Don't use that way. You can try that another
approach: https://play.golang.org/p/Nu8zD1stOd
Em segunda-feira, 20 de novembro de 2017 14:48:31 UTC-2, Trig escreveu:
>
> for i, user := range myList {
> if user.Disabled {
> myList = append(myList[:i], myList[i + 1:]...) // remove user from
> re