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 {
The best way to do it is to use the append function:
package main import ( "fmt" ) func main() { x := []int{4, 5, 6, 7, 88} fmt.Println(x) x = append(x[:2], x[4:]...)//deletes 6 and 7 fmt.Println(x) }
https://play.golang.org/p/-EEFCsqse4u