/stringcases

Golang string package to convert to various string cases

Primary LanguageGoMIT LicenseMIT

stringcases

GoDoc Build Status codecov.io

GitHub contributors Last Commit

This is a string package written in go which is used to convert the strings to different case styles. The commonly used strategies are: camel case, pascal case, snake case, and kebab case.

Installation

This requires Go version 1.11 or later.

go get -u github.com/parithiban/stringcases

Usage

The following are some of the methods that can be used from the package.

ConvertToSnake  Convert a string from any format to snake_case.
ConvertToKebab  Convert a string from any format to kebab-case.
ConvertToPascal Convert a string from any format to PascalCase.
ConvertToCamel  Convert a string from any format to camelCase.

Example

ConvertToSnake("ConvertToSnakeCase") =>  convert_to_snake_case
ConvertToKebab("convert_to_kebab_case") => convert-to-kebab-case.
ConvertToPascal("convert-to-pascal-case") => ConvertToPascalCase.
ConvertToCamel("convert to camel case") => convertToCamelCase.