a Go library for string case manipulation. it is always uses Builder.Write methods to efficiently build a string and minimizes memory copying.
go get github.com/mohprilaksono/str-case
import str_case "github.com/mohprilaksono/str-case"
str_case.Apa("Thomas And Friends") //Thomas and Friends
str_case.Sponge("HTML is not a programming language") // hTmL Is nOt A ProGraMmINg LanGuAgE
Converts the given string to Ada_Case.
import str_case "github.com/mohprilaksono/str-case"
var value = str_case.Ada("helloWorld")
// Hello_World
Converts the given string to Title Case, following the APA Guidelines.
import str_case "github.com/mohprilaksono/str-case"
var value = str_case.Apa("Thomas And Friends")
// Thomas and Friends
Converts the given string to camelCase.
import str_case "github.com/mohprilaksono/str-case"
var value = str_case.Camel("hello_world")
// helloWorld
Converts the given string to COBOL-CASE.
import str_case "github.com/mohprilaksono/str-case"
var value = str_case.Cobol("helloWorld")
// HELLO-WORLD
Converts the given string to kebab-case.
import str_case "github.com/mohprilaksono/str-case"
var value = str_case.Kebab("helloWorld")
// hello-world
Converts the given string with the first-character lowercased.
import str_case "github.com/mohprilaksono/str-case"
var value = str_case.LcFirst("HelloWorld")
// helloWorld
Converts the given string to MACRO_CASE.
import str_case "github.com/mohprilaksono/str-case"
var value = str_case.Macro("helloWorld")
// HELLO_WORLD
Converts the given string to snake_case.
import str_case "github.com/mohprilaksono/str-case"
var value = str_case.Snake("helloWorld")
// hello_world
Converts the given string to sPoNGeCAse, it is usually used for creating a "Mocking SpongeBob" meme.
import str_case "github.com/mohprilaksono/str-case"
var value = str_case.Sponge("HTML is not a programming language")
// hTmL Is nOt A ProGraMmINg LanGuAgE
Converts the given string to StudlyCase.
import str_case "github.com/mohprilaksono/str-case"
var value = str_case.Studly("hello_world")
// HelloWorld
Swap the case of the given string.
import str_case "github.com/mohprilaksono/str-case"
var value = str_case.Swap("HelloWorlD")
// hELLOwORLd
Converts the given string to Title Case.
import str_case "github.com/mohprilaksono/str-case"
var value = str_case.Title("hello world")
// Hello World
Converts the given string to Train-Case.
import str_case "github.com/mohprilaksono/str-case"
var value = str_case.Train("helloWorld")
// Hello-World
Converts the given string with the first-character uppercased.
import str_case "github.com/mohprilaksono/str-case"
var value = str_case.UcFirst("helloWorld")
// HelloWorld
- none
github.com/stretchr/testify
go test -v