package main
import (
"fmt"
)
func RemoveByIndex(slice []int, index int) []int {
return append(slice[:index], slice[index + 1:]...)
}
func find(a []int, val int) int {
for i, n := range a {
if n == val {
return i
}
}
return -1
}
func main() {
slice := []int{4, 6, 12, 45, 98, 77, 32, 5, 1, 99, 100}
fmt.Println(slice)
slice = RemoveByIndex(slice, find(slice, 77))
fmt.Println(slice)
}
/*
run:
[4 6 12 45 98 77 32 5 1 99 100]
[4 6 12 45 98 32 5 1 99 100]
*/