Have a slice of ints and a function that accepts a pointer to a slice as a parameter.
mainSlice := []int{0,8,5,4,6,9,7,1,2,3,6,4,5,7}
doSmthWithSlice(mainSlice)
Is there any ways to get the slice item using the pointer to the slice, but without copying the value that the pointer points into new slice?
func doSmthWithSlice(slcPtr *[]int) {
*slcPtr[3] = 777 // this does NOT works, because *[]int does not support indexing
// Don't want to implement it
// like this
newSlice := *slcPtr
newSlice[3] = 777
*slcPtr = newSlice
}
Thank you
P.S.
Sorry for asking this kind of primitive question. I'm new in go