stringcase

package
v0.64.5 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2024 License: MIT Imports: 8 Imported by: 9

Documentation

Index

Constants

View Source
const (
	CamelCase  = "camelCase"
	KebabCase  = "kebab-case"
	PascalCase = "PascalCase"
	SnakeCase  = "snake_case"
)

Variables

View Source
var ErrUnknownCaseString = errors.New("unknown case string")

Functions

func CaseKebabToCamel

func CaseKebabToCamel(s string) string

func CaseKebabToPascal

func CaseKebabToPascal(s string) string

func CaseKebabToSnake

func CaseKebabToSnake(s string) string

func CaseSnakeToCamel

func CaseSnakeToCamel(s string) string

func CaseSnakeToKebab

func CaseSnakeToKebab(s string) string

func CaseSnakeToPascal

func CaseSnakeToPascal(s string) string

func FuncToCase added in v0.58.0

func FuncToCase(c string) (func(string) string, error)

FuncToCase returns to the ToXCase function given a case.

func FuncToCaseMore added in v0.58.0

func FuncToCaseMore(c string, overrides map[string]string) (func(string) string, error)

FuncToCaseMore returns the function to convert case.

func FuncToWantCaseOrDefault added in v0.41.10

func FuncToWantCaseOrDefault(c string, defaultFunc func(string) string) func(string) string

FuncToWantCaseOrDefault returns an ToWantCase function, or default if case is not preseent or parseable. For flexibility, if a `nil` func is passed, `nil`, is returned.

func FuncToWantCaseOrNoOp added in v0.41.10

func FuncToWantCaseOrNoOp(c string) func(string) string

func IsCamelCase

func IsCamelCase(input string) bool

IsCamelCase returns if a string is camelCase or not.

func IsCase

func IsCase(caseType, s string) (bool, error)

func IsFirstAlphaUpper

func IsFirstAlphaUpper(s string) bool

IsFirstAlphaUpper returns if the first character is a capital [A-Z] character.

func IsKebabCase

func IsKebabCase(input string) bool

func IsPascalCase

func IsPascalCase(input string) bool

IsPascalCase returns if a string is PascalCase or not.

func IsSnakeCase

func IsSnakeCase(input string) bool

func Join added in v0.58.0

func Join(elems []string, sep string, wantCase string) (string, error)

func NoOp added in v0.41.10

func NoOp(s string) string

func Parse

func Parse(s string) (string, error)

func ToCamelCase

func ToCamelCase(s string) string

ToCamelCase converts a string to camel case as `camelCase`.

func ToCase added in v0.58.0

func ToCase(c, s string) (string, error)

func ToKebabCase added in v0.40.7

func ToKebabCase(s string) string

func ToPascalCase

func ToPascalCase(s string) string

ToPascalCase converts a string to Pascal case as `PascalCase`.

func ToSnakeCase added in v0.40.7

func ToSnakeCase(s string) string

Types

This section is empty.

Jump to

Keyboard shortcuts

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