This is not nice if you want to reuse the slice, and still may leak the
fields.

clients[i] = clients[len(clients)-1]
// If the current clients[i] is deleted it becomes inaccessible
// and the ipAddr, name and conn fields potentially leak, so
// zero them in the last position of the slice.
clients[len(clients)-1] = connInfo{}
clients = clients[:len(clients)-1]


On Mon, 2017-09-25 at 11:52 -0700, Tamás Gulácsi wrote:
> https://github.com/golang/go/wiki/SliceTricks
> 
> clients[i] = clients[0]
> clients = clients[1:]



-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to