kace: github.com/codemodus/kace Index | Examples | Files | Directories

package kace

import "github.com/codemodus/kace"

Package kace provides common case conversion functions which take into consideration common initialisms.

Code:

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

Package Files

kace.go

func Camel Uses

func Camel(s string) string

Camel returns a camelCased string.

func Kebab Uses

func Kebab(s string) string

Kebab returns a kebab-cased string with all lowercase letters.

func KebabUpper Uses

func KebabUpper(s string) string

KebabUpper returns a KEBAB-CASED string with all upper case letters.

func Pascal Uses

func Pascal(s string) string

Pascal returns a PascalCased string.

func Snake Uses

func Snake(s string) string

Snake returns a snake_cased string with all lowercase letters.

func SnakeUpper Uses

func SnakeUpper(s string) string

SnakeUpper returns a SNAKE_CASED string with all upper case letters.

type Kace Uses

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 Uses

func New(initialisms map[string]bool) (*Kace, error)

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) Camel Uses

func (k *Kace) Camel(s string) string

Camel returns a camelCased string.

func (*Kace) Kebab Uses

func (k *Kace) Kebab(s string) string

Kebab returns a kebab-cased string with all lowercase letters.

func (*Kace) KebabUpper Uses

func (k *Kace) KebabUpper(s string) string

KebabUpper returns a KEBAB-CASED string with all upper case letters.

func (*Kace) Pascal Uses

func (k *Kace) Pascal(s string) string

Pascal returns a PascalCased string.

func (*Kace) Snake Uses

func (k *Kace) Snake(s string) string

Snake returns a snake_cased string with all lowercase letters.

func (*Kace) SnakeUpper Uses

func (k *Kace) SnakeUpper(s string) string

SnakeUpper returns a SNAKE_CASED string with all upper case letters.

Directories

PathSynopsis
ktrie

Package kace imports 4 packages (graph) and is imported by 7 packages. Updated 2018-08-27. Refresh now. Tools for package owners.