Help us shape the future of Go! Take the 2026 Go Developer Survey

go_case

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 15, 2018 License: MIT Imports: 2 Imported by: 3

README

go-case

Package to convert names, titles and sequences to snake_case, CamelCase and some other.

import (
    "fmt"

    "github.com/vetcher/go-case"
)

func main() {
    s := "some string to convert"
    fmt.Println(go_case.ToCamelCase(s))

    // Output:
    // SomeStringToConvert
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ToSnakeCase converts string to snake_case.
	ToSnakeCase = ToSomeCaseWithSep('_', unicode.ToLower)
	// ToLowerCase is a shortcut for strings.ToLower.
	ToLowerCase = strings.ToLower
	// ToUrlSnakeCase works like ToSnakeCase except fills spaces with `-`.
	ToUrlSnakeCase = ToSomeCaseWithSep('-', unicode.ToLower)
	// ToDotSnakeCase works like ToSnakeCase except fills spaces with `.`(dot).
	ToDotSnakeCase = ToSomeCaseWithSep('.', unicode.ToLower)
	// ToCamelCase converts string to CamelCase. All space symbols, `_`, `.` and `-` will be removed. First symbol will be capital.
	ToCamelCase = toCamelCase(true, unicode.ToUpper)
	// ToCamelCase converts string to CamelCase. All space symbols, `_`, `.` and `-` will be removed. First symbol will be capital.
	ToCamelCaseLowerFirst = toCamelCaseLower()
	// ToNoCase returns input's string. Should be used for mocking, tests, etc.
	ToNoCase = func(s string) string { return s }
)

Functions

func ToSomeCaseWithSep

func ToSomeCaseWithSep(sep rune, runeConv func(rune) rune) func(string) string

ToSomeCaseWithSep allow to get customized converter, that will work as ToSnakeCase, but with your rules.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL