Capitalizes the first letter of a string.

Use strings.ToUpper() to capitalize the first letter of the string.

代码实现

import "strings"

func Capitalize(s string) string {
    return strings.ToUpper(s[0:1]) + s[1:]
}

使用样例

Capitalize("boomerang") // "Boomerang"