Files
config/definition/generate/pkg/alias.go
andrey f9a0411192
All checks were successful
Go Action / goaction (push) Successful in 29s
def (#12)
Reviewed-on: #12
2025-12-26 14:55:42 +03:00

30 lines
468 B
Go

package pkg
import (
"strings"
"unicode"
)
func AliasName(name string) string {
data := strings.Builder{}
toUp := false
for _, char := range name {
isLeter := unicode.IsLetter(char)
isAllowed := isLeter || unicode.IsDigit(char)
switch {
case isAllowed && !toUp:
data.WriteRune(char)
case !isAllowed && data.Len() > 0:
toUp = true
case toUp:
data.WriteString(strings.ToUpper(string(char)))
toUp = false
}
}
return data.String()
}