[Solved] i am getting index out of range error on running the below code


copy_numbers is of size 0, just as you initialized it.

If I add the following before your first for loop:

fmt.Println(numbers)
fmt.Println(copy_numbers)

I get:

[5 2 3 5 3]
[]

the copy builtin copies up to the length of either argument, as mentioned in the docs:

Copy returns the number of elements copied, which will be the minimum
of len(src) and len(dst).

You should initialize copy_numbers to be of the same length as numbers

  copy_numbers := make([]int, len(numbers))

solved i am getting index out of range error on running the below code