I have a simple code for removing element from slice:
package main
import "fmt"
func main() {
values := []string{"1", "2", "3", "4", "5"}
valuesResult := removeElementByIndex(values2, 0)
fmt.Printf("%v - %v\n", values, valuesResult)
}
func removeElementByIndex[T interface{}](a []T, i int) []T {
return append(a[:i], a[i+1:]...)
}
but output is
[2 3 4 5 5] - [2 3 4 5]
For some reason values
are changing, but i didnt change it in my method (i guess). Please help me to fix it