diff options
Diffstat (limited to 'vendor/github.com/99designs/gqlgen/codegen/templates')
-rw-r--r-- | vendor/github.com/99designs/gqlgen/codegen/templates/import.go | 3 | ||||
-rw-r--r-- | vendor/github.com/99designs/gqlgen/codegen/templates/templates.go | 14 |
2 files changed, 10 insertions, 7 deletions
diff --git a/vendor/github.com/99designs/gqlgen/codegen/templates/import.go b/vendor/github.com/99designs/gqlgen/codegen/templates/import.go index effe9a0d..d5bd16a6 100644 --- a/vendor/github.com/99designs/gqlgen/codegen/templates/import.go +++ b/vendor/github.com/99designs/gqlgen/codegen/templates/import.go @@ -4,6 +4,7 @@ import ( "fmt" "go/types" "strconv" + "strings" "github.com/99designs/gqlgen/internal/code" ) @@ -20,7 +21,7 @@ type Imports struct { } func (i *Import) String() string { - if i.Alias == i.Name { + if strings.HasSuffix(i.Path, i.Alias) { return strconv.Quote(i.Path) } diff --git a/vendor/github.com/99designs/gqlgen/codegen/templates/templates.go b/vendor/github.com/99designs/gqlgen/codegen/templates/templates.go index f2fcb568..5d5f69bf 100644 --- a/vendor/github.com/99designs/gqlgen/codegen/templates/templates.go +++ b/vendor/github.com/99designs/gqlgen/codegen/templates/templates.go @@ -285,7 +285,8 @@ func ToGoPrivate(name string) string { first := true wordWalker(name, func(info *wordInfo) { word := info.Word - if first { + switch { + case first: if strings.ToUpper(word) == word || strings.ToLower(word) == word { // ID → id, CAMEL → camel word = strings.ToLower(info.Word) @@ -294,9 +295,9 @@ func ToGoPrivate(name string) string { word = lcFirst(info.Word) } first = false - } else if info.MatchCommonInitial { + case info.MatchCommonInitial: word = strings.ToUpper(word) - } else if !info.HasCommonInitial { + case !info.HasCommonInitial: word = ucFirst(strings.ToLower(word)) } runes = append(runes, []rune(word)...) @@ -319,9 +320,10 @@ func wordWalker(str string, f func(*wordInfo)) { hasCommonInitial := false for i+1 <= len(runes) { eow := false // whether we hit the end of a word - if i+1 == len(runes) { + switch { + case i+1 == len(runes): eow = true - } else if isDelimiter(runes[i+1]) { + case isDelimiter(runes[i+1]): // underscore; shift the remainder forward over any run of underscores eow = true n := 1 @@ -336,7 +338,7 @@ func wordWalker(str string, f func(*wordInfo)) { copy(runes[i+1:], runes[i+n+1:]) runes = runes[:len(runes)-n] - } else if unicode.IsLower(runes[i]) && !unicode.IsLower(runes[i+1]) { + case unicode.IsLower(runes[i]) && !unicode.IsLower(runes[i+1]): // lower->non-lower eow = true } |