Documentation ¶
Overview ¶
Package naming provides methods to parse and build compound names for variables types, functions, classes or other structures in source code.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CamelCase ¶
CamelCase applies the Fields method on s and returns a string with all the words capitalized after the first one.
Example ¶
package main import ( "fmt" "github.com/rvflash/naming" ) func main() { fmt.Println(naming.CamelCase("camel case data-19")) }
Output: camelCaseData19
func ConstantCase ¶
ConstantCase applies the Fields method on s and returns a string with all the words capitalized and joined with an underscore.
Example ¶
package main import ( "fmt" "github.com/rvflash/naming" ) func main() { fmt.Println(naming.ConstantCase("cgo enabled")) }
Output: CGO_ENABLED
func Fields ¶
Fields splits the string s around each instance of one or more consecutive white space characters, underscore or hyphen. Its also break title words. It returns a slice of substrings of s or an empty slice if s contains only white space, underscore or hyphen.
Example ¶
package main import ( "fmt" "github.com/rvflash/naming" ) func main() { fmt.Println(naming.Fields("This isA really-sample XML_or_Whatever data")) }
Output: [This is A really sample XML or Whatever data]
func FlatCase ¶
FlatCase applies the Fields method on s and concatenates any words to return only one in lowercase.
Example ¶
package main import ( "fmt" "github.com/rvflash/naming" ) func main() { fmt.Println(naming.FlatCase("go-toolDir")) }
Output: gotooldir
func KebabCase ¶
KebabCase applies the Fields method on s and returns a string with a hyphen between each word and all of them are lowercase.
Example ¶
package main import ( "fmt" "github.com/rvflash/naming" ) func main() { fmt.Println(naming.KebabCase("kebab-case Data_19")) }
Output: kebab-case-data-19
func PascalCase ¶
PascalCase applies the Fields method on s and returns a string with all the words capitalized.
Example ¶
package main import ( "fmt" "github.com/rvflash/naming" ) func main() { fmt.Println(naming.PascalCase("camel case data-19")) }
Output: CamelCaseData19
func SnakeCase ¶
SnakeCase applies the Fields method on s and returns a string with an underscore between each word and all of them are lowercase.
Example ¶
package main import ( "fmt" "github.com/rvflash/naming" ) func main() { fmt.Println(naming.SnakeCase("kebab-case Data_19")) }
Output: kebab_case_data_19
func TrainCase ¶
TrainCase applies the Fields method on s and returns a string with all the words capitalized and separated with a hyphen.
Example ¶
package main import ( "fmt" "github.com/rvflash/naming" ) func main() { fmt.Println(naming.TrainCase("HTTP header case")) }
Output: HTTP-Header-Case
func UpperFlatCase ¶
UpperFlatCase applies the Fields method on s and concatenates any words to return only one in uppercase.
Example ¶
package main import ( "fmt" "github.com/rvflash/naming" ) func main() { fmt.Println(naming.UpperFlatCase("Go_Host arch")) }
Output: GOHOSTARCH
Types ¶
This section is empty.