To reverse an array in go, we can use the standard library function reverse
from the sort
package. Here's a sample code to reverse an array:
main.go229 chars17 lines
In the code above, we first define an int
array arr
with values 1, 2, 3, 4, 5
. We then use the sort.Reverse
function to reverse the array and print the result.
gistlibby LogSnag