refactored doc to please golint
This commit is contained in:
parent
d73be125f8
commit
dfc5dc8c6d
4
camel.go
4
camel.go
@ -58,12 +58,12 @@ func toCamelInitCase(s string, initCase bool) string {
|
||||
return n
|
||||
}
|
||||
|
||||
// Converts a string to CamelCase
|
||||
// ToCamel converts a string to CamelCase
|
||||
func ToCamel(s string) string {
|
||||
return toCamelInitCase(s, true)
|
||||
}
|
||||
|
||||
// Converts a string to lowerCamelCase
|
||||
// ToLowerCamel converts a string to lowerCamelCase
|
||||
func ToLowerCamel(s string) string {
|
||||
if s == "" {
|
||||
return s
|
||||
|
12
doc.go
Normal file
12
doc.go
Normal file
@ -0,0 +1,12 @@
|
||||
// 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 |
|
||||
package strcase
|
13
snake.go
13
snake.go
@ -23,39 +23,38 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
// Package strcase converts strings to snake_case or CamelCase
|
||||
package strcase
|
||||
|
||||
import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Converts a string to snake_case
|
||||
// ToSnake converts a string to snake_case
|
||||
func ToSnake(s string) string {
|
||||
return ToDelimited(s, '_')
|
||||
}
|
||||
|
||||
// Converts a string to SCREAMING_SNAKE_CASE
|
||||
// ToScreamingSnake converts a string to SCREAMING_SNAKE_CASE
|
||||
func ToScreamingSnake(s string) string {
|
||||
return ToScreamingDelimited(s, '_', true)
|
||||
}
|
||||
|
||||
// Converts a string to kebab-case
|
||||
// ToKebab converts a string to kebab-case
|
||||
func ToKebab(s string) string {
|
||||
return ToDelimited(s, '-')
|
||||
}
|
||||
|
||||
// Converts a string to SCREAMING-KEBAB-CASE
|
||||
// ToScreamingKebab converts a string to SCREAMING-KEBAB-CASE
|
||||
func ToScreamingKebab(s string) string {
|
||||
return ToScreamingDelimited(s, '-', true)
|
||||
}
|
||||
|
||||
// Converts a string to delimited.snake.case (in this case `del = '.'`)
|
||||
// ToDelimited converts a string to delimited.snake.case (in this case `del = '.'`)
|
||||
func ToDelimited(s string, del uint8) string {
|
||||
return ToScreamingDelimited(s, del, false)
|
||||
}
|
||||
|
||||
// Converts a string to SCREAMING.DELIMITED.SNAKE.CASE (in this case `del = '.'; screaming = true`) or delimited.snake.case (in this case `del = '.'; screaming = false`)
|
||||
// ToScreamingDelimited converts a string to SCREAMING.DELIMITED.SNAKE.CASE (in this case `del = '.'; screaming = true`) or delimited.snake.case (in this case `del = '.'; screaming = false`)
|
||||
func ToScreamingDelimited(s string, del uint8, screaming bool) string {
|
||||
s = addWordBoundariesToNumbers(s)
|
||||
s = strings.Trim(s, " ")
|
||||
|
Loading…
Reference in New Issue
Block a user