On Tue, May 19, 2020 at 9:53 AM <anderson.mill.r...@gmail.com> wrote:
>
> I am using go-1.14.1. I am using this code to remove i-th element from the 
> slice.
>
> s = append(s[:i], s[i+1:]...)
>
> It works on my machine but gives panic on docker-container with error "range 
> out of bound" when it has just 1 element left.
>
> I want to check if this is an unsafe code and how can I improve this?

It's hard to tell with only a code fragment.  The line you show will
crash if i >= len(s).

Ian

-- 
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/CAOyqgcUdMiJLvdfYe9%2B7fzjeuwJtu6uGxmW3UE-%3D%2BZ2DQLU%3D1Q%40mail.gmail.com.

Reply via email to