Skip to content

Instantly share code, notes, and snippets.

@larzconwell
Created July 30, 2012 20:03
Show Gist options
  • Save larzconwell/3209686 to your computer and use it in GitHub Desktop.
Save larzconwell/3209686 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
)
func Reverse(slice []string) []string {
ret := make([]string, len(slice), cap(slice))
for i := len(slice) - 1; i >= 0; i-- {
ret = append(ret, slice[i])
}
return ret
}
func main() {
slice := []string{"c", "b", "a"}
fmt.Printf("%v, %v\n", Reverse(slice), []string{"a", "b", "c"})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment