0xBF
0xBF

0xBF

Series

Go Cheatsheet


Articles in this series

Go cheatsheet - Slice Utilities

Apr 19, 20212 min read

Slice Empty a slice a := []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10} a = a[:0] // or a = nil Prepend b := []int{2, 3, 4} b = append([]int{1}, b...) Remove a = append(a[:i], a[i+1:]...) Insert at index s = append(s, 0) copy(s[i+1:], s[i:]) s[i] = x Index...