Home / Go / slice tricks edit

AppendVector: a = append(a, b...)

Copy: b = make([]T, len(a))
copy(b, a)

Cut: a = append(a[:i], a[j:]...)

Delete: a = append(a[:i], a[i+1:]...)
// or
a = a[:i+copy(a[i:], a[i+1:])]

Delete without preserving order: a[i], a = a[len(a)-1], a[:len(a)-1]

func Sort(slice interface{}, less func(i, j int) bool)
Go to index of articles.

Feedback about page:

Optional: your email if you want me to get back to you:

Share on