Golang: Cut Slice (Delete Elements)

By Xah Lee. Date: .

Cut Slice (Delete Elements)

Use append to delete elements, like this:

append(s[:i], s[j:]...)

Delete from index i to j.

package main

import "fmt"

func main() {

	var x = []byte("0123456")

	x = append(x[:3], x[5:]...)

	fmt.Printf("%s\n", x)
	// 1236

}

Golang, array and slice