Documentation
¶
Overview ¶
Package casing helps convert between CamelCase, snake_case, and others. It includes an intelligent `Split` function to take almost any input and then convert it to any type of casing.
Index ¶
- func Camel(value string, transform ...TransformFunc) string
- func Identity(part string) string
- func Initialism(part string) string
- func Join(parts []string, sep string, transform ...TransformFunc) string
- func Kebab(value string, transform ...TransformFunc) string
- func LowerCamel(value string, transform ...TransformFunc) string
- func MergeNumbers(parts []string, suffixes ...string) []string
- func Snake(value string, transform ...TransformFunc) string
- func Split(value string) []string
- type TransformFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Camel ¶
func Camel(value string, transform ...TransformFunc) string
Camel returns a CamelCase version of the input. If no transformation functions are passed in, then strings.ToLower is used. This can be disabled by passing in the identity function.
func Initialism ¶
Initialism converts common initialisms like ID and HTTP to uppercase.
func Join ¶
func Join(parts []string, sep string, transform ...TransformFunc) string
Join will combine split parts back together with the given separator and optional transform functions.
func Kebab ¶
func Kebab(value string, transform ...TransformFunc) string
Kebab returns a kabob-case version of the input.
func LowerCamel ¶
func LowerCamel(value string, transform ...TransformFunc) string
LowerCamel returns a lowerCamelCase version of the input.
func MergeNumbers ¶
MergeNumbers will merge some number parts with their adjacent letter parts to support a smarter delimited join. For example, `h264` instead of `h_264` or `mp3-player` instead of `mp-3-player`. You can pass suffixes for right aligning certain items, e.g. `K` to get `MODE_4K` instead of `MODE4_K`. If no suffixes are passed, then a default set of common ones is used. Pass an empty string to disable the default.
func Snake ¶
func Snake(value string, transform ...TransformFunc) string
Snake returns a snake_case version of the input.
Types ¶
type TransformFunc ¶
TransformFunc is used to transform parts of a split string during joining.