Go doesn't have a built-in reverse function. Write one yourself:
func reverse(s []int) {
for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {
s[i], s[j] = s[j], s[i]
}
}
This swaps elements from the ends toward the middle. It modifies the slice in place. Since Go , you can use slices.Reverse from the slices package instead.