str_case

package module
v0.8.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 13, 2024 License: MIT Imports: 5 Imported by: 0

README

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Ada added in v0.8.5

func Ada(value string) string

func Apa

func Apa(value string) string

func Camel

func Camel(value string) string

func Cobol added in v0.8.5

func Cobol(value string) string

func Kebab

func Kebab(value string) string

func LcFirst

func LcFirst(value string) string

func Macro added in v0.8.5

func Macro(value string) string

func Snake

func Snake(value string) string

func Sponge added in v0.5.0

func Sponge(value string) string

func Studly

func Studly(value string) string

func Swap added in v0.8.5

func Swap(value string) string

func Title added in v0.7.0

func Title(value string) string

func Train added in v0.8.5

func Train(value string) string

func UcFirst

func UcFirst(value string) string

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL