Documentation
¶
Overview ¶
Package strcase converts strings to various cases. See the conversion table below:
| Function | Result | |---------------------------------|--------------------| | ToSnake(s) | any_kind_of_string | | ToScreamingSnake(s) | ANY_KIND_OF_STRING | | ToKebab(s) | any-kind-of-string | | ToScreamingKebab(s) | ANY-KIND-OF-STRING | | ToDelimited(s, '.') | any.kind.of.string | | ToScreamingDelimited(s, '.') | ANY.KIND.OF.STRING | | ToCamel(s) | AnyKindOfString | | ToLowerCamel(s) | anyKindOfString |
Index ¶
- Constants
- type Context
- func (a Context) ToCamel(s string) string
- func (ctx Context) ToDelimited(s string, delimiter uint8) string
- func (ctx Context) ToKebab(s string) string
- func (a Context) ToLowerCamel(s string) string
- func (ctx Context) ToScreamingDelimited(s string, delimiter uint8, ignore string, screaming bool) string
- func (ctx Context) ToScreamingKebab(s string) string
- func (ctx Context) ToScreamingSnake(s string) string
- func (ctx Context) ToSnake(s string) string
- func (ctx Context) ToSnakeWithIgnore(s string, ignore string) string
Constants ¶
View Source
const ( Other byteType = iota Upper Lower Separator Digit )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶ added in v0.13.0
type Context struct {
// contains filtered or unexported fields
}
func New ¶ added in v0.13.0
New creates a new context with the given acronyms.
Examples:
- "API": "api"
- "K8s": "k8s"
- "3D": "3d"
- `A(1\d{3})`: "a$l1}"
- `(\d)[vV](\d)`: "${1}v${2}"
func (Context) ToDelimited ¶ added in v0.13.0
ToDelimited converts a string to delimited.snake.case (in this case `delimiter = '.'`)
func (Context) ToLowerCamel ¶ added in v0.13.0
ToLowerCamel converts a string to lowerCamelCase
func (Context) ToScreamingDelimited ¶ added in v0.13.0
func (ctx Context) ToScreamingDelimited(s string, delimiter uint8, ignore string, screaming bool) string
ToScreamingDelimited converts a string to SCREAMING.DELIMITED.SNAKE.CASE (in this case `delimiter = '.'; screaming = true`) or delimited.snake.case (in this case `delimiter = '.'; screaming = false`)
func (Context) ToScreamingKebab ¶ added in v0.13.0
ToScreamingKebab converts a string to SCREAMING-KEBAB-CASE
func (Context) ToScreamingSnake ¶ added in v0.13.0
ToScreamingSnake converts a string to SCREAMING_SNAKE_CASE
Click to show internal directories.
Click to hide internal directories.