I was having some issues with Golang slices.
I understand that a slice is a pointer to an underlying array, but some of the behaviour feels a little odd.
I was trying to remove an item from a slice I managed to do it by copying the slice is there a better way?
In the code below the original slice is changed.
package main
import (
"fmt"
)
func main() {
mySlice := []int{1,2,3,4,5,6}
pos := 3
slicePart1 := mySlice[:pos+1]
slicePart2 := mySlice[pos+2:]
fmt.Println(mySlice)
fmt.Println(slicePart1)
fmt.Println(slicePart2)
new := append(slicePart1,slicePart2...)
fmt.Println(new)
fmt.Println(mySlice)
}