Documentation ¶
Overview ¶
Package name implements various naming conventions. The two categories are delimiter-separated and letter case-separated words. Each of the formatting functions support both techniques for input, without any context.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CamelCase ¶
CamelCase returns the medial capitals form of the words in s. Words consist of Unicode letters and/or numbers in any order. Upper case sequences [abbreviations] are preserved.
Argument upper forces the letter case for the first rune. Use true for UpperCamelCase, a.k.a. PascalCase. Use false for lowerCamelCase, a.k.a. dromedaryCase.
BUG(pascaldekloe): Abbreviations at the beginning of a name may look odd in lowerCamelCase, i.e., "tCPConn".
BUG(pascaldekloe): CamelCase concatenates abbreviations by design, i.e., "DB-API" becomes "DBAPI".
Example ¶
package main import ( "fmt" "github.com/pascaldekloe/name" ) func main() { fmt.Println(name.CamelCase("pascal case", true)) fmt.Println(name.CamelCase("snake_to_camel AND CamelToCamel?", false)) }
Output: PascalCase snakeToCamelANDCamelToCamel
func Delimit ¶
Delimit returns the words in s delimited with separator sep. Words consist of Unicode letters and/or numbers in any order. Upper case sequences [abbreviations] are preserved. Use strings.ToLower or ToUpper to enforce one letter case.
Example ¶
package main import ( "fmt" "github.com/pascaldekloe/name" ) func main() { // Garbage to lisp-case: fmt.Println(name.Delimit("* All Hype is aGoodThing (TM)", '-')) // Extract a Java property key: fmt.Println(name.DotSeparated("WebCrawler#socketTimeout")) }
Output: all-hype-is-a-good-thing-TM web.crawler.socket.timeout
func DotSeparated ¶
DotSeparated returns Delimit(s, '.'), a.k.a. the dot notation.
Types ¶
This section is empty.
Notes ¶
Bugs ¶
Abbreviations at the beginning of a name may look odd in lowerCamelCase, i.e., "tCPConn".
CamelCase concatenates abbreviations by design, i.e., "DB-API" becomes "DBAPI".