Documentation ¶
Overview ¶
Package kace provides common case conversion functions which take into consideration common initialisms.
Example ¶
package main import ( "fmt" "github.com/codemodus/kace" ) func main() { s := "this is a test sql." fmt.Println(kace.Camel(s)) fmt.Println(kace.Pascal(s)) fmt.Println(kace.Snake(s)) fmt.Println(kace.SnakeUpper(s)) fmt.Println(kace.Kebab(s)) fmt.Println(kace.KebabUpper(s)) customInitialisms := map[string]bool{ "THIS": true, } k, err := kace.New(customInitialisms) if err != nil { // handle error } fmt.Println(k.Camel(s)) fmt.Println(k.Pascal(s)) fmt.Println(k.Snake(s)) fmt.Println(k.SnakeUpper(s)) fmt.Println(k.Kebab(s)) fmt.Println(k.KebabUpper(s)) }
Output: thisIsATestSQL ThisIsATestSQL this_is_a_test_sql THIS_IS_A_TEST_SQL this-is-a-test-sql THIS-IS-A-TEST-SQL thisIsATestSql THISIsATestSql this_is_a_test_sql THIS_IS_A_TEST_SQL this-is-a-test-sql THIS-IS-A-TEST-SQL
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func KebabUpper ¶
KebabUpper returns a KEBAB-CASED string with all upper case letters.
func SnakeUpper ¶
SnakeUpper returns a SNAKE_CASED string with all upper case letters.
Types ¶
type Kace ¶ added in v0.3.0
type Kace struct {
// contains filtered or unexported fields
}
Kace provides common case conversion methods which take into consideration common initialisms set by the user.
func New ¶ added in v0.3.0
New returns a pointer to an instance of kace loaded with a common initialsms trie based on the provided map. Before conversion to a trie, the provided map keys are all upper cased.
func (*Kace) KebabUpper ¶ added in v0.3.0
KebabUpper returns a KEBAB-CASED string with all upper case letters.
func (*Kace) SnakeUpper ¶ added in v0.3.0
SnakeUpper returns a SNAKE_CASED string with all upper case letters.