Skip to content

Instantly share code, notes, and snippets.

@gnilchee
Last active February 28, 2016 01:11
Show Gist options
  • Save gnilchee/824e722a5087abf35a83 to your computer and use it in GitHub Desktop.
Save gnilchee/824e722a5087abf35a83 to your computer and use it in GitHub Desktop.
Formatting mixed case string variables to capitalized words
package main
import (
"fmt"
"strings"
)
func main() {
name := "aMANDA aNyBOdY"
fmt.Println("Your name is", Capitalize(name))
}
func Capitalize(s string) string {
s = strings.Title(strings.ToLower(s))
return s
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment