Skip to content

Instantly share code, notes, and snippets.

@husobee
Created October 1, 2016 02:36
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 husobee/efa8fb99cd8c37b13ee40326821832af to your computer and use it in GitHub Desktop.
Save husobee/efa8fb99cd8c37b13ee40326821832af to your computer and use it in GitHub Desktop.
reverse a string
package main
import (
"fmt"
)
func reverseStr(s string) string {
input := []byte(s)
for i := 0; i < len(input)/2; i++ {
input[i], input[(len(input)-1)-i] = input[(len(input)-1)-i], input[i]
}
return string(input)
}
func main() {
fmt.Println(reverseStr("blahes"))
}
@husobee
Copy link
Author

husobee commented Oct 1, 2016

sehalb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment