Skip to content

dc0d/caseconv

Repository files navigation

PkgGoDev Go Report Card Maintainability Test Coverage

caseconv

This is a Go Module for snake, kebab, camel, pascal case conversion.

It can be used like:

package main

import (
	"fmt"

	"github.com/dc0d/caseconv"
)

func main() {
	input := "The quick brown fox jumps over the lazy dog"

	fmt.Println(caseconv.ToCamel(input))
	fmt.Println(caseconv.ToPascal(input))
	fmt.Println(caseconv.ToKebab(input))
	fmt.Println(caseconv.ToSnake(input))
}

And the output would be:

theQuickBrownFoxJumpsOverTheLazyDog
TheQuickBrownFoxJumpsOverTheLazyDog
the-quick-brown-fox-jumps-over-the-lazy-dog
the_quick_brown_fox_jumps_over_the_lazy_dog

Most of test cases are from change-case node package - so far. But the goal was not to follow same conventions.