diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..c586c74 --- /dev/null +++ b/go.mod @@ -0,0 +1,5 @@ +module github.com/alvaroloes/enumer + +go 1.12 + +require github.com/pascaldekloe/name v0.0.0-20180628100202-0fd16699aae1 diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..e21b462 --- /dev/null +++ b/go.sum @@ -0,0 +1,2 @@ +github.com/pascaldekloe/name v0.0.0-20180628100202-0fd16699aae1 h1:/I3lTljEEDNYLho3/FUB7iD/oc2cEFgVmbHzV+O0PtU= +github.com/pascaldekloe/name v0.0.0-20180628100202-0fd16699aae1/go.mod h1:eD5JxqMiuNYyFNmyY9rkJ/slN8y59oEu4Ei7F8OoKWQ= diff --git a/vendor/github.com/pascaldekloe/name/LICENSE b/vendor/github.com/pascaldekloe/name/LICENSE deleted file mode 100644 index 8dc57b4..0000000 --- a/vendor/github.com/pascaldekloe/name/LICENSE +++ /dev/null @@ -1,3 +0,0 @@ -To the extent possible under law, Pascal S. de Kloe has waived all -copyright and related or neighboring rights to Colfer. This work is -published from The Netherlands. diff --git a/vendor/github.com/pascaldekloe/name/README.md b/vendor/github.com/pascaldekloe/name/README.md deleted file mode 100644 index 68436c6..0000000 --- a/vendor/github.com/pascaldekloe/name/README.md +++ /dev/null @@ -1,6 +0,0 @@ -[![GoDoc](https://godoc.org/github.com/pascaldekloe/name?status.svg)](https://godoc.org/github.com/pascaldekloe/name) - -Naming convention library for the Go programming language (golang). - -This is free and unencumbered software released into the -[public domain](http://creativecommons.org/publicdomain/zero/1.0). diff --git a/vendor/github.com/pascaldekloe/name/case.go b/vendor/github.com/pascaldekloe/name/case.go deleted file mode 100644 index d464944..0000000 --- a/vendor/github.com/pascaldekloe/name/case.go +++ /dev/null @@ -1,112 +0,0 @@ -// Package name implements naming conventions. -package name - -import "unicode" - -// CamelCase returns the medial capitals form of word sequence s. -// The input can be any case or even just a bunch of words. -// Upper case abbreviations are preserved. -// Argument upper sets the casing for the first rune. -func CamelCase(s string, upper bool) string { - if s == "" { - return "" - } - - out := make([]rune, 1, len(s)+5) - for i, r := range s { - if i == 0 { - if upper { - r = unicode.ToUpper(r) - } - out[0] = r - continue - } - - if i == 1 { - if !upper && unicode.Is(unicode.Lower, r) { - out[0] = unicode.ToLower(out[0]) - } - - upper = false - } - - switch { - case unicode.IsLetter(r): - if upper { - r = unicode.ToUpper(r) - } - - fallthrough - case unicode.IsNumber(r): - upper = false - out = append(out, r) - - default: - upper = true - - } - } - - return string(out) -} - -// SnakeCase is an alias for Delimit(s, '_'). -func SnakeCase(s string) string { - return Delimit(s, '_') -} - -// DotSeparated is an alias for Delimit(s, '.'). -func DotSeparated(s string) string { - return Delimit(s, '.') -} - -// Delimit returns word sequence s delimited with sep. -// The input can be any case or even just a bunch of words. -// Upper case abbreviations are preserved. Use strings.ToLower -// and strings.ToUpper to enforce a letter case. -func Delimit(s string, sep rune) string { - out := make([]rune, 0, len(s)+5) - - for _, r := range s { - switch { - case unicode.IsUpper(r): - if last := len(out) - 1; last >= 0 && unicode.IsLower(out[last]) { - out = append(out, sep) - } - - case unicode.IsLetter(r): - if i := len(out) - 1; i >= 0 { - if last := out[i]; unicode.IsUpper(last) { - out = out[:i] - if i > 0 && out[i-1] != sep { - out = append(out, sep) - } - out = append(out, unicode.ToLower(last)) - } - } - - case !unicode.IsNumber(r): - if i := len(out); i != 0 && out[i-1] != sep { - out = append(out, sep) - } - continue - - } - out = append(out, r) - } - - if len(out) == 0 { - return "" - } - - // trim tailing separator - if i := len(out) - 1; out[i] == sep { - out = out[:i] - } - - if len(out) == 1 { - out[0] = unicode.ToLower(out[0]) - } - - return string(out) -} diff --git a/vendor/github.com/pascaldekloe/name/case_test.go b/vendor/github.com/pascaldekloe/name/case_test.go deleted file mode 100644 index 46bd578..0000000 --- a/vendor/github.com/pascaldekloe/name/case_test.go +++ /dev/null @@ -1,103 +0,0 @@ -package name - -import ( - "testing" -) - -type goldenCase struct { - snake, lowerCamel, upperCamel string -} - -var goldenCases = []goldenCase{ - {"", "", ""}, - {"i", "i", "I"}, - {"name", "name", "Name"}, - {"ID", "ID", "ID"}, - {"wi_fi", "wiFi", "WiFi"}, - - // single outer abbreviation - {"vitamin_C", "vitaminC", "VitaminC"}, - {"T_cell", "TCell", "TCell"}, - - // double outer abbreviation - {"master_DB", "masterDB", "MasterDB"}, - {"IO_bounds", "IOBounds", "IOBounds"}, - - // tripple outer abbreviation - {"main_API", "mainAPI", "MainAPI"}, - {"TCP_conn", "TCPConn", "TCPConn"}, - - // inner abbreviation - {"raw_URL_query", "rawURLQuery", "RawURLQuery"}, - - // numbers - {"4x4", "4x4", "4x4"}, - {"no5", "no5", "No5"}, - {"DB2", "DB2", "DB2"}, - {"3M", "3M", "3M"}, - {"7_up", "7Up", "7Up"}, - {"20th", "20th", "20th"}, -} - -func TestSnakeToSnake(t *testing.T) { - for _, golden := range goldenCases { - s := golden.snake - if got := SnakeCase(s); got != s { - t.Errorf("%q: got %q", s, got) - } - } -} - -func TestLowerCamelToLowerCamel(t *testing.T) { - for _, golden := range goldenCases { - s := golden.lowerCamel - if got := CamelCase(s, false); got != s { - t.Errorf("%q: got %q", s, got) - } - } -} - -func TestUpperCamelToUpperCamel(t *testing.T) { - for _, golden := range goldenCases { - s := golden.upperCamel - if got := CamelCase(s, true); got != s { - t.Errorf("%q: got %q", s, got) - } - } -} - -func TestSnakeToLowerCamel(t *testing.T) { - for _, golden := range goldenCases { - snake, want := golden.snake, golden.lowerCamel - if got := CamelCase(snake, false); got != want { - t.Errorf("%q: got %q, want %q", snake, got, want) - } - } -} - -func TestSnakeToUpperCamel(t *testing.T) { - for _, golden := range goldenCases { - snake, want := golden.snake, golden.upperCamel - if got := CamelCase(snake, true); got != want { - t.Errorf("%q: got %q, want %q", snake, got, want) - } - } -} - -func TestLowerCamelToSnake(t *testing.T) { - for _, golden := range goldenCases { - camel, want := golden.lowerCamel, golden.snake - if got := SnakeCase(camel); got != want { - t.Errorf("%q: got %q, want %q", camel, got, want) - } - } -} - -func TestUpperCamelToSnake(t *testing.T) { - for _, golden := range goldenCases { - camel, want := golden.upperCamel, golden.snake - if got := SnakeCase(camel); got != want { - t.Errorf("%q: got %q, want %q", camel, got, want) - } - } -} diff --git a/vendor/github.com/pascaldekloe/name/example_test.go b/vendor/github.com/pascaldekloe/name/example_test.go deleted file mode 100644 index 1106630..0000000 --- a/vendor/github.com/pascaldekloe/name/example_test.go +++ /dev/null @@ -1,27 +0,0 @@ -package name_test - -import ( - "fmt" - "github.com/pascaldekloe/name" -) - -func ExampleCamelCase() { - fmt.Println(name.CamelCase("pascal case", true)) - fmt.Println(name.CamelCase("snake_to_camel AND CamelToCamel?", false)) - - // Output: - // PascalCase - // snakeToCamelANDCamelToCamel -} - -func ExampleDelimit() { - // Garbage to Lisp-case: - fmt.Println(name.Delimit("* All Hype is aGoodThing (TM)", '-')) - - // Builds a Java property key: - fmt.Println(name.DotSeparated("WebCrawler#socketTimeout")) - - // Output: - // all-hype-is-a-good-thing-TM - // web.crawler.socket.timeout -}