Answers for "remove item from slice golang"

Go
7

golang delete element from array

func RemoveIndex(s []string, index int) []string {
	return append(s[:index], s[index+1:]...)
}
Posted by: Guest on June-25-2020
2

go delete from slice

func remove(slice []int, s int) []int {
    return append(slice[:s], slice[s+1:]...)
}
Posted by: Guest on April-10-2020
0

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:]...)
}
Posted by: Guest on October-24-2021
0

golang array remove item

a[i] = a[len(a)-1] 
a = a[:len(a)-1]
Posted by: Guest on March-18-2021

Code answers related to "remove item from slice golang"

Browse Popular Code Answers by Language