Last active
February 28, 2016 01:11
-
-
Save gnilchee/824e722a5087abf35a83 to your computer and use it in GitHub Desktop.
Formatting mixed case string variables to capitalized words
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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