Skip to content

mohprilaksono/str-case

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

str_case

a Go library for string case manipulation. it is always uses Builder.Write methods to efficiently build a string and minimizes memory copying.

Install

go get github.com/mohprilaksono/str-case

Example

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

Usage

Ada

Converts the given string to Ada_Case.

import str_case "github.com/mohprilaksono/str-case"

var value = str_case.Ada("helloWorld") 

// Hello_World

Apa

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

Camel

Converts the given string to camelCase.

import str_case "github.com/mohprilaksono/str-case"

var value = str_case.Camel("hello_world") 

// helloWorld

Cobol

Converts the given string to COBOL-CASE.

import str_case "github.com/mohprilaksono/str-case"

var value = str_case.Cobol("helloWorld") 

// HELLO-WORLD

Kebab

Converts the given string to kebab-case.

import str_case "github.com/mohprilaksono/str-case"

var value = str_case.Kebab("helloWorld") 

// hello-world

LcFirst

Converts the given string with the first-character lowercased.

import str_case "github.com/mohprilaksono/str-case"

var value = str_case.LcFirst("HelloWorld") 

// helloWorld

Macro

Converts the given string to MACRO_CASE.

import str_case "github.com/mohprilaksono/str-case"

var value = str_case.Macro("helloWorld") 

// HELLO_WORLD

Snake

Converts the given string to snake_case.

import str_case "github.com/mohprilaksono/str-case"

var value = str_case.Snake("helloWorld") 

// hello_world

Sponge

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

Studly

Converts the given string to StudlyCase.

import str_case "github.com/mohprilaksono/str-case"

var value = str_case.Studly("hello_world") 

// HelloWorld

Swap

Swap the case of the given string.

import str_case "github.com/mohprilaksono/str-case"

var value = str_case.Swap("HelloWorlD") 

// hELLOwORLd

Title

Converts the given string to Title Case.

import str_case "github.com/mohprilaksono/str-case"

var value = str_case.Title("hello world") 

// Hello World

Train

Converts the given string to Train-Case.

import str_case "github.com/mohprilaksono/str-case"

var value = str_case.Train("helloWorld") 

// Hello-World

UcFirst

Converts the given string with the first-character uppercased.

import str_case "github.com/mohprilaksono/str-case"

var value = str_case.UcFirst("helloWorld") 

// HelloWorld

Dependencies

Build dependencies

  • none

Test dependencies

  • github.com/stretchr/testify

Running Tests

go test -v

About

a Go library for string case manipulation

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages