Skip to content

xogas/stringcase

Repository files navigation

stringcase

stringcase is a go package for converting string case to various cases (e.g. sbake case or camel case)

Example

Function Result
ToSnakeCase("testCase") test_case
ToSnakeCaseWithIgnore("test-case", "-") test-case
ToScreamingSnakeCase("testCase") TEST_CASE
ToKebabCase("testCase") test-case
ToScreamingKebabCase("testCase") TEST-CASE
ToDelimitedCase("testCase", "-") test-case
ToScreamingDelimitedCase("testCase", "-", true) TEST-CASE

Install

go get -u github.com/xogas/stringcase

Custom Acronyms for ToCamelCase and ToSnakeCase

import "github.com/xogas/stringcase"

func init() {
    // results in "Api" using ToCamelCase("API")
    // results in "api" using ToPascalCase("API")
    stringcase.ConfigureAcronyms("API", "api")

    // results in "PostgreSQL" using ToCamelCase("PostgreSQL")
    // results in "postgreSQL" using ToPascalCase("PostgreSQL")
    strcase.ConfigureAcronym("PostgreSQL", "PostgreSQL")
}

About

A Golang package for converting to snake_case or CamelCase

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages