strcase

package module
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2021 License: MIT Imports: 2 Imported by: 20

README

go-strcase

Convert between string case styles

Doc

strcase - GoDoc

Documentation

Index

Examples

Constants

This section is empty.

Variables

View Source
var CommonInitialisms = map[string]bool{
	"acl":   true,
	"api":   true,
	"ascii": true,
	"cpu":   true,
	"css":   true,
	"dns":   true,
	"eof":   true,
	"guid":  true,
	"html":  true,
	"http":  true,
	"https": true,
	"id":    true,
	"ip":    true,
	"json":  true,
	"lhs":   true,
	"qps":   true,
	"ram":   true,
	"rhs":   true,
	"rpc":   true,
	"sla":   true,
	"smtp":  true,
	"sql":   true,
	"ssh":   true,
	"tcp":   true,
	"tls":   true,
	"ttl":   true,
	"udp":   true,
	"ui":    true,
	"uid":   true,
	"uuid":  true,
	"uri":   true,
	"url":   true,
	"utf8":  true,
	"vm":    true,
	"xml":   true,
	"xmpp":  true,
	"xsrf":  true,
	"xss":   true,
}

from https://github.com/golang/lint

Functions

func SplitIntoWords

func SplitIntoWords(s string) []string

func SplitIntoWordsWithInitialisms added in v1.0.1

func SplitIntoWordsWithInitialisms(s string, initialisms map[string]bool) []string

func ToLowerCamel

func ToLowerCamel(s string) string
Example
fmt.Println(strcase.ToLowerCamel("lowerCamel"))
fmt.Println(strcase.ToLowerCamel("UpperCamel"))
fmt.Println(strcase.ToLowerCamel("lower_snake"))
fmt.Println(strcase.ToLowerCamel("UPPER_SNAKE"))
Output:

lowerCamel
upperCamel
lowerSnake
upperSnake

func ToLowerCamelWithInitialisms added in v1.0.1

func ToLowerCamelWithInitialisms(s string, initialisms map[string]bool) string

func ToLowerSnake

func ToLowerSnake(s string) string
Example
fmt.Println(strcase.ToLowerSnake("lowerCamel"))
fmt.Println(strcase.ToLowerSnake("UpperCamel"))
fmt.Println(strcase.ToLowerSnake("lower_snake"))
fmt.Println(strcase.ToLowerSnake("UPPER_SNAKE"))
Output:

lower_camel
upper_camel
lower_snake
upper_snake

func ToUpperCamel

func ToUpperCamel(s string) string
Example
fmt.Println(strcase.ToUpperCamel("lowerCamel"))
fmt.Println(strcase.ToUpperCamel("UpperCamel"))
fmt.Println(strcase.ToUpperCamel("lower_snake"))
fmt.Println(strcase.ToUpperCamel("UPPER_SNAKE"))
Output:

LowerCamel
UpperCamel
LowerSnake
UpperSnake

func ToUpperCamelWithInitialisms added in v1.0.1

func ToUpperCamelWithInitialisms(s string, initialisms map[string]bool) string

func ToUpperSnake

func ToUpperSnake(s string) string
Example
fmt.Println(strcase.ToUpperSnake("lowerCamel"))
fmt.Println(strcase.ToUpperSnake("UpperCamel"))
fmt.Println(strcase.ToUpperSnake("lower_snake"))
fmt.Println(strcase.ToUpperSnake("UPPER_SNAKE"))
Output:

LOWER_CAMEL
UPPER_CAMEL
LOWER_SNAKE
UPPER_SNAKE

Types

This section is empty.

Jump to

Keyboard shortcuts

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