camelcase

package
v0.0.0-...-30a8ca0 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: MIT Imports: 5 Imported by: 2

Documentation

Index

Constants

View Source
const (
	RuneOther = iota
	RuneLower
	RuneUpper
	RuneDigit
)

Variables

View Source
var (
	LowerSnakeCase = makeCase("_", wrap(strings.ToLower))
	UpperSnakeCase = makeCase("_", wrap(strings.ToUpper))
	LowerKebabCase = makeCase("-", wrap(strings.ToLower))
	UpperKebabCase = makeCase("-", wrap(strings.ToUpper))
	LowerCamelCase = makeCase("", func(w string, i int) string {
		if i == 0 {
			return strings.ToLower(w)
		}
		return cases.Title(language.Und).String(w)
	})
	UpperCamelCase = makeCase("", func(w string, i int) string {
		return cases.Title(language.Und).String(w)
	})
)

Functions

func Split

func Split(src string) (entries []string)

Split splits the camelcase word and returns a list of words. It also supports digits. Both lower camel case and upper camel case are supported. For more info please check: http://en.wikipedia.org/wiki/CamelCase Splitting rules

  1. If string is not valid UTF-8, return it without splitting as single item array.
  2. Assign all unicode characters into one of 4 sets: lower case letters, upper case letters, numbers, and all other characters.
  3. Iterate through characters of string, introducing splits between adjacent characters that belong to different sets.
  4. Iterate through array of split strings, and if a given string is upper case: if subsequent string is lower case: move last character of upper case string to beginning of lower case string

Types

type RuneType

type RuneType int

Jump to

Keyboard shortcuts

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