sx

package module
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 17, 2025 License: MIT Imports: 4 Imported by: 0

README

sx

Go Reference

TODO Description

Installation

go get github.com/gomantics/sx

Documentation

Index

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

func LowerFirst(s string) string

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

func UpperFirst(s string) string

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

type StringOrStringSlice interface {
	string | []string
}

StringOrStringSlice represents input that can be either a string or slice of strings

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL