caseconv

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package caseconv provides text case conversion utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Convert

func Convert(s string, caseType CaseType) string

Convert converts a string to the specified case

func ConvertAll

func ConvertAll(s string) map[CaseType]string

ConvertAll converts a string to all case types

func RunCase

func RunCase(w io.Writer, args []string, opts Options) error

RunCase executes case conversion

func ToCamel

func ToCamel(s string) string

ToCamel converts to camelCase

func ToConstant

func ToConstant(s string) string

ToConstant converts to CONSTANT_CASE

func ToDot

func ToDot(s string) string

ToDot converts to dot.case

func ToKebab

func ToKebab(s string) string

ToKebab converts to kebab-case

func ToLower

func ToLower(s string) string

ToLower converts to lowercase

func ToPascal

func ToPascal(s string) string

ToPascal converts to PascalCase

func ToPath

func ToPath(s string) string

ToPath converts to path/case

func ToSentence

func ToSentence(s string) string

ToSentence converts to Sentence case

func ToSnake

func ToSnake(s string) string

ToSnake converts to snake_case

func ToSwap

func ToSwap(s string) string

ToSwap swaps case of each character

func ToTitle

func ToTitle(s string) string

ToTitle converts to Title Case

func ToToggle

func ToToggle(s string) string

ToToggle toggles the first character's case

func ToUpper

func ToUpper(s string) string

ToUpper converts to UPPERCASE

Types

type CaseType

type CaseType string

CaseType represents the case convention

const (
	CaseUpper    CaseType = "upper"    // UPPERCASE
	CaseLower    CaseType = "lower"    // lowercase
	CaseTitle    CaseType = "title"    // Title Case
	CaseSentence CaseType = "sentence" // Sentence case
	CaseCamel    CaseType = "camel"    // camelCase
	CasePascal   CaseType = "pascal"   // PascalCase
	CaseSnake    CaseType = "snake"    // snake_case
	CaseKebab    CaseType = "kebab"    // kebab-case
	CaseConstant CaseType = "constant" // CONSTANT_CASE
	CaseDot      CaseType = "dot"      // dot.case
	CasePath     CaseType = "path"     // path/case
	CaseSwap     CaseType = "swap"     // sWAP cASE
	CaseToggle   CaseType = "toggle"   // Toggle first char
)

func DetectCase

func DetectCase(s string) CaseType

DetectCase detects the case type of a string

func ParseCaseType

func ParseCaseType(s string) (CaseType, error)

ParseCaseType parses a string into a CaseType

func ValidCaseTypes

func ValidCaseTypes() []CaseType

ValidCaseTypes returns all valid case types

type ListResult

type ListResult struct {
	Case    string   `json:"case"`
	Results []Result `json:"results"`
}

ListResult represents multiple conversion results

type Options

type Options struct {
	Case CaseType // Target case type
	JSON bool     // Output as JSON
}

Options configures case conversion

type Result

type Result struct {
	Input  string `json:"input"`
	Output string `json:"output"`
	Case   string `json:"case"`
}

Result represents conversion result

Jump to

Keyboard shortcuts

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