fmt.Println(\"Enter position to delete::\")
fmt.Scanln(&pos)
new_arr := make([]int, (len(arr) - 1))
k := 0
for i := 0; i < (len(arr) - 1); {
if i != pos {
Maybe this code will help.
It deletes item with a given index.
Takes the array, and the index to delete and returns a new array pretty much like append function.
func deleteItem(arr []int, index int) []int{
if index < 0 || index >= len(arr){
return []int{-1}
}
for i := index; i < len(arr) -1; i++{
arr[i] = arr[i + 1]
}
return arr[:len(arr)-1]
}
Here you can play with the code : https://play.golang.org/p/aX1Qj40uTVs