forked from mirror/enumer
Add title-lower transform
This commit is contained in:
parent
d806ebd41f
commit
188f5ebedc
|
@ -136,9 +136,10 @@ name := MyTypeValue.String() // name => "my_type_value"
|
|||
- snake-upper
|
||||
- kebab
|
||||
- kebab-upper
|
||||
- lower (Lowercase)
|
||||
- upper (Uppercase)
|
||||
- lower (lowercase)
|
||||
- upper (UPPERCASE)
|
||||
- title (TitleCase)
|
||||
- title-lower (titleCase)
|
||||
- first (Use first character of string)
|
||||
- first-lower (same as first only lower case)
|
||||
- first-upper (same as first only upper case)
|
||||
|
|
|
@ -27,6 +27,7 @@ import (
|
|||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
"unicode"
|
||||
"unicode/utf8"
|
||||
|
||||
"github.com/pascaldekloe/name"
|
||||
|
@ -272,6 +273,12 @@ func (g *Generator) transformValueNames(values []Value, transformMethod string)
|
|||
fn = func(s string) string {
|
||||
return strings.Title(s)
|
||||
}
|
||||
case "title-lower":
|
||||
fn = func(s string) string {
|
||||
title := []rune(strings.Title(s))
|
||||
title[0] = unicode.ToLower(title[0])
|
||||
return string(title)
|
||||
}
|
||||
case "first":
|
||||
fn = func(s string) string {
|
||||
r, _ := utf8.DecodeRuneInString(s)
|
||||
|
|
Loading…
Reference in New Issue