cases

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Is

func Is(s string, target Case) bool

Is returns true if s is in the target case.

func IsComplexCase

func IsComplexCase(s string) bool

IsComplexCase returns true if s is in one of the recognized naming conventions: PascalCase, camelCase, snake_case, kebab-case, Header-Case, or hybrid_Case.

func IsHybridCase

func IsHybridCase(s string) bool

IsHybridCase returns true if the string contains a mix of separators (e.g., both "-" and "_") and a mix of casing that does not conform strictly to one of the standard conventions.

func SplitWords

func SplitWords(s string) []string

SplitWords attempts to split an input string into words. It handles strings that use underscores, hyphens, or camel/pascal style, and works well for hybrid cases (mixing these conventions).

func TransformTo

func TransformTo(s string, target Case) string

TransformTo transforms a given string into a target Case. It supports determined cases only, but not Hybrid. For Hybrid use TransformToHybrid.

Types

type Case

type Case string

Case defines the target naming convention.

const (
	Snake      Case = "snake"       // e.g. "hello_world"
	Camel      Case = "camel"       // e.g. "helloWorld"
	Pascal     Case = "pascal"      // e.g. "HelloWorld"
	Kebab      Case = "kebab"       // e.g. "hello-world"
	Header     Case = "header"      // e.g. "Hello-World"
	TitleSnake Case = "title_snake" // e.g. "Hello_World"
	Hybrid     Case = "hybrid"      // e.g. "Hello_beautiful-WorldHere"
)

Jump to

Keyboard shortcuts

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