[Go] Remove an element from a slice by index

Created on November 30, 2026

Use append to join the portion of the slice before the element to the portion after it. Here, arr1[:2] contains the first two elements and arr1[3:] starts just after three.

package main

import "fmt"

func main() {
    arr1 := []string{"one", "two", "three", "four", "five"}
    arr2 := append(arr1[:2], arr1[3:]...)

    fmt.Printf("%#v", arr2)
}

Output

[]string{"one", "two", "four", "five"}
Go