go delete from slice
func remove(slice []int, s int) []int {
return append(slice[:s], slice[s+1:]...)
}
go delete from slice
func remove(slice []int, s int) []int {
return append(slice[:s], slice[s+1:]...)
}
delete element in slice golang
package main
import "fmt"
func main() {
var strSlice = []string{"India", "Canada", "Japan", "Germany", "Italy"}
fmt.Println(strSlice)
strSlice = RemoveIndex(strSlice, 3)
fmt.Println(strSlice)
}
func RemoveIndex(s []string, index int) []string {
return append(s[:index], s[index+1:]...)
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us