Documentation
¶
Index ¶
- func CamelCase[T StringOrStringSlice](input T, opts ...CaseOption) string
- func FlatCase[T StringOrStringSlice](input T) string
- func KebabCase[T StringOrStringSlice](input T, separator ...string) string
- func LowerFirst(s string) string
- func PascalCase[T StringOrStringSlice](input T, opts ...CaseOption) string
- func SnakeCase[T StringOrStringSlice](input T) string
- func SplitByCase(s string, opts ...SplitOption) []string
- func TrainCase[T StringOrStringSlice](input T, opts ...CaseOption) string
- func UpperFirst(s string) string
- type CaseConfig
- type CaseOption
- type SplitConfig
- type SplitOption
- type StringOrStringSlice
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CamelCase ¶
func CamelCase[T StringOrStringSlice](input T, opts ...CaseOption) string
CamelCase converts input to camelCase
func FlatCase ¶
func FlatCase[T StringOrStringSlice](input T) string
FlatCase converts input to flatcase (no separators)
func KebabCase ¶
func KebabCase[T StringOrStringSlice](input T, separator ...string) string
KebabCase converts input to kebab-case
func LowerFirst ¶
LowerFirst converts the first character to lowercase
func PascalCase ¶
func PascalCase[T StringOrStringSlice](input T, opts ...CaseOption) string
PascalCase converts input to PascalCase
func SnakeCase ¶
func SnakeCase[T StringOrStringSlice](input T) string
SnakeCase converts input to snake_case
func SplitByCase ¶
func SplitByCase(s string, opts ...SplitOption) []string
SplitByCase splits a string into words based on case changes and separators Accepts optional configuration via functional options
func TrainCase ¶
func TrainCase[T StringOrStringSlice](input T, opts ...CaseOption) string
TrainCase converts input to Train-Case
func UpperFirst ¶
UpperFirst converts the first character to uppercase
Types ¶
type CaseConfig ¶
type CaseConfig struct { // If an uppercase letter is followed by other uppercase letters (like FooBAR), they are preserved. You can use sx.WithNormalize(true) for strictly following PascalCase convention. Normalize bool }
CaseConfig configures case conversion behavior
type CaseOption ¶
type CaseOption func(*CaseConfig)
func WithNormalize ¶
func WithNormalize(normalize bool) CaseOption
WithNormalize sets the normalize option
type SplitConfig ¶
type SplitConfig struct {
Separators []rune
}
SplitConfig holds the configuration for splitting behavior
type SplitOption ¶
type SplitOption func(*SplitConfig)
SplitOption configures how SplitByCase splits strings
func WithSeparators ¶
func WithSeparators(separators ...rune) SplitOption
WithSeparators sets custom separator runes (replaces defaults)
type StringOrStringSlice ¶
StringOrStringSlice represents input that can be either a string or slice of strings