https://pkg.go.dev/github.com/dtomasi/gocc
go get github.com/dtomasi/gocc
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