Here is a function to remove the element at a particular index:
package main
import "fmt"
import "errors"
func main() {
strings := []string{}
strings = append(strings, "one")
strings = append(strings, "two")
strings = append(strings, "three")
strings, err := remove(strings, 1)
if err != nil {
fmt.Println("Something went wrong : ", err)
} else {
fmt.Println(strings)
}
}
func remove(s []string, index int) ([]string, error) {
if index >= len(s) {
return nil, errors.New("Out of Range Error")
}
return append(s[:index], s[index+1:]...), nil
}
Try it on Go Playground