Skip to content
/ gocc Public

A Go package for case style conversion/manipulation. Supports snake_case, PascalCase, camelCase, kebab-case, dot.notation and custom delimiters

License

Notifications You must be signed in to change notification settings

dtomasi/gocc

Repository files navigation

gocc (Golang Case Converter)

Go Reference CodeFactor pre-commit.ci status Go Unit Tests CodeQL codecov

Documentation

https://pkg.go.dev/github.com/dtomasi/gocc

Installation

go get github.com/dtomasi/gocc

Usage

import (
    "github.com/dtomasi/gocc"
)

func func main() {
    // Convert string to snake case -> returns "my_camel_case_string"
    // Input case style is automatically detected
    gocc.C("myCamelCaseString").ToSnakeCase()

    // Convert with known input type
    // Using Convert function with known type is much faster than the example above,
    // because there is no need to detect the input type
    gocc.C("myCamelCaseString").Convert(gocc.StyleCamelCase, gocc.StyleSnakeCase)

    // Validate strings -> returns true
    gocc.IsSnakeCase("my_snake_case_string")

    // Case type checking -> returns StyleKebabCase (int)
    gocc.C("kebab-case-string").Style()
    // returns "kebab"
    gocc.C("kebab-case-string").Style().String()
}

For a full list of available functions see documentation

About

A Go package for case style conversion/manipulation. Supports snake_case, PascalCase, camelCase, kebab-case, dot.notation and custom delimiters

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages