Skip to content

Instantly share code, notes, and snippets.

@rickt
Last active August 29, 2015 14:02
Show Gist options
  • Save rickt/d779eab14e81a04ff5ac to your computer and use it in GitHub Desktop.
Save rickt/d779eab14e81a04ff5ac to your computer and use it in GitHub Desktop.
palindrome tester
package main
import (
"fmt"
"os"
)
// func main
func main() {
var s string = os.Args[1]
fmt.Println(palindrome(s))
}
// func palindrome
func palindrome(s string) bool {
return reverse(s) == s
}
// func reverse
func reverse(s string) string {
var rs string
for _, r := range s {
rs = string(r) + rs
}
return rs
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment