Skip to content

Instantly share code, notes, and snippets.

@shemul
Created September 25, 2020 10:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shemul/7aff4b09e250f5b4ea30457bb099a823 to your computer and use it in GitHub Desktop.
Save shemul/7aff4b09e250f5b4ea30457bb099a823 to your computer and use it in GitHub Desktop.
golang generic example
package main
import "fmt"
func reverse(arr []interface{}) interface{} {
var i = 0
var j = len(arr) - 1
for i < j {
tmp := arr[i]
arr[i] = arr[j]
arr[j] = tmp
i++
j--
}
return arr
}
func main() {
fmt.Println(reverse([]interface{}{"a","b","c"}))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment