Skip to content

Commit

Permalink
Merge pull request #44 from dmarkham/dan/issue-43
Browse files Browse the repository at this point in the history
Return the same string passed for error
  • Loading branch information
dmarkham authored Jul 22, 2021
2 parents 677b61c + b85f109 commit 9d0b7d4
Show file tree
Hide file tree
Showing 20 changed files with 39 additions and 39 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ matrix:
allow_failures:
- go: master
include:
- go: 1.14.x
- go: 1.15.x
- go: 1.16.x
- go: master
env:
global:
Expand All @@ -24,6 +24,6 @@ deploy:
- cli/build/enumer.windows-amd64.exe.tar.gz
- cli/build/sha256sum.txt
on:
go: 1.15.x
go: 1.16.x
repo: dmarkham/enumer
tags: true
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Enumer [![GoDoc](https://godoc.org/github.com/dmarkham/enumer?status.svg)](https://godoc.org/github.com/dmarkham/enumer) [![Go Report Card](https://goreportcard.com/badge/github.com/dmarkham/enumer)](https://goreportcard.com/report/github.com/dmarkham/enumer) [![GitHub Release](https://img.shields.io/github/release/dmarkham/enumer.svg)](https://github.com/dmarkham/enumer/releases)[![Build Status](https://travis-ci.org/dmarkham/enumer.svg?branch=master)](https://travis-ci.org/dmarkham/enumer)
# Enumer [![GoDoc](https://godoc.org/github.com/dmarkham/enumer?status.svg)](https://godoc.org/github.com/dmarkham/enumer) [![Go Report Card](https://goreportcard.com/badge/github.com/dmarkham/enumer)](https://goreportcard.com/report/github.com/dmarkham/enumer) [![GitHub Release](https://img.shields.io/github/release/dmarkham/enumer.svg)](https://github.com/dmarkham/enumer/releases)[![Build Status](https://travis-ci.com/dmarkham/enumer.svg?branch=master)](https://travis-ci.com/dmarkham/enumer)


Enumer is a tool to generate Go code that adds useful methods to Go enums (constants with a specific type).
Expand Down
4 changes: 2 additions & 2 deletions enumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ func %[1]sString(s string) (%[1]s, error) {
if val, ok := _%[1]sNameToValueMap[s]; ok {
return val, nil
}
s = strings.ToLower(s)
if val, ok := _%[1]sNameToValueMap[s]; ok {
if val, ok := _%[1]sNameToValueMap[strings.ToLower(s)]; ok {
return val, nil
}
return 0, fmt.Errorf("%%s does not belong to %[1]s values", s)
Expand Down
4 changes: 2 additions & 2 deletions testdata/day.golden
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ func DayString(s string) (Day, error) {
if val, ok := _DayNameToValueMap[s]; ok {
return val, nil
}
s = strings.ToLower(s)
if val, ok := _DayNameToValueMap[s]; ok {

if val, ok := _DayNameToValueMap[strings.ToLower(s)]; ok {
return val, nil
}
return 0, fmt.Errorf("%s does not belong to Day values", s)
Expand Down
4 changes: 2 additions & 2 deletions testdata/dayTrimAndPrefix.golden
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ func DayString(s string) (Day, error) {
if val, ok := _DayNameToValueMap[s]; ok {
return val, nil
}
s = strings.ToLower(s)
if val, ok := _DayNameToValueMap[s]; ok {

if val, ok := _DayNameToValueMap[strings.ToLower(s)]; ok {
return val, nil
}
return 0, fmt.Errorf("%s does not belong to Day values", s)
Expand Down
4 changes: 2 additions & 2 deletions testdata/dayWithLinecomment.golden
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ func DayString(s string) (Day, error) {
if val, ok := _DayNameToValueMap[s]; ok {
return val, nil
}
s = strings.ToLower(s)
if val, ok := _DayNameToValueMap[s]; ok {

if val, ok := _DayNameToValueMap[strings.ToLower(s)]; ok {
return val, nil
}
return 0, fmt.Errorf("%s does not belong to Day values", s)
Expand Down
4 changes: 2 additions & 2 deletions testdata/dayWithPrefix.golden
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ func DayString(s string) (Day, error) {
if val, ok := _DayNameToValueMap[s]; ok {
return val, nil
}
s = strings.ToLower(s)
if val, ok := _DayNameToValueMap[s]; ok {

if val, ok := _DayNameToValueMap[strings.ToLower(s)]; ok {
return val, nil
}
return 0, fmt.Errorf("%s does not belong to Day values", s)
Expand Down
4 changes: 2 additions & 2 deletions testdata/gap.golden
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ func GapString(s string) (Gap, error) {
if val, ok := _GapNameToValueMap[s]; ok {
return val, nil
}
s = strings.ToLower(s)
if val, ok := _GapNameToValueMap[s]; ok {

if val, ok := _GapNameToValueMap[strings.ToLower(s)]; ok {
return val, nil
}
return 0, fmt.Errorf("%s does not belong to Gap values", s)
Expand Down
4 changes: 2 additions & 2 deletions testdata/num.golden
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ func NumString(s string) (Num, error) {
if val, ok := _NumNameToValueMap[s]; ok {
return val, nil
}
s = strings.ToLower(s)
if val, ok := _NumNameToValueMap[s]; ok {

if val, ok := _NumNameToValueMap[strings.ToLower(s)]; ok {
return val, nil
}
return 0, fmt.Errorf("%s does not belong to Num values", s)
Expand Down
4 changes: 2 additions & 2 deletions testdata/offset.golden
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ func NumberString(s string) (Number, error) {
if val, ok := _NumberNameToValueMap[s]; ok {
return val, nil
}
s = strings.ToLower(s)
if val, ok := _NumberNameToValueMap[s]; ok {

if val, ok := _NumberNameToValueMap[strings.ToLower(s)]; ok {
return val, nil
}
return 0, fmt.Errorf("%s does not belong to Number values", s)
Expand Down
4 changes: 2 additions & 2 deletions testdata/prime.golden
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ func PrimeString(s string) (Prime, error) {
if val, ok := _PrimeNameToValueMap[s]; ok {
return val, nil
}
s = strings.ToLower(s)
if val, ok := _PrimeNameToValueMap[s]; ok {

if val, ok := _PrimeNameToValueMap[strings.ToLower(s)]; ok {
return val, nil
}
return 0, fmt.Errorf("%s does not belong to Prime values", s)
Expand Down
4 changes: 2 additions & 2 deletions testdata/primeGQLGen.golden
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ func PrimeString(s string) (Prime, error) {
if val, ok := _PrimeNameToValueMap[s]; ok {
return val, nil
}
s = strings.ToLower(s)
if val, ok := _PrimeNameToValueMap[s]; ok {

if val, ok := _PrimeNameToValueMap[strings.ToLower(s)]; ok {
return val, nil
}
return 0, fmt.Errorf("%s does not belong to Prime values", s)
Expand Down
4 changes: 2 additions & 2 deletions testdata/primeJson.golden
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ func PrimeString(s string) (Prime, error) {
if val, ok := _PrimeNameToValueMap[s]; ok {
return val, nil
}
s = strings.ToLower(s)
if val, ok := _PrimeNameToValueMap[s]; ok {

if val, ok := _PrimeNameToValueMap[strings.ToLower(s)]; ok {
return val, nil
}
return 0, fmt.Errorf("%s does not belong to Prime values", s)
Expand Down
4 changes: 2 additions & 2 deletions testdata/primeJsonAndSql.golden
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ func PrimeString(s string) (Prime, error) {
if val, ok := _PrimeNameToValueMap[s]; ok {
return val, nil
}
s = strings.ToLower(s)
if val, ok := _PrimeNameToValueMap[s]; ok {

if val, ok := _PrimeNameToValueMap[strings.ToLower(s)]; ok {
return val, nil
}
return 0, fmt.Errorf("%s does not belong to Prime values", s)
Expand Down
4 changes: 2 additions & 2 deletions testdata/primeSql.golden
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ func PrimeString(s string) (Prime, error) {
if val, ok := _PrimeNameToValueMap[s]; ok {
return val, nil
}
s = strings.ToLower(s)
if val, ok := _PrimeNameToValueMap[s]; ok {

if val, ok := _PrimeNameToValueMap[strings.ToLower(s)]; ok {
return val, nil
}
return 0, fmt.Errorf("%s does not belong to Prime values", s)
Expand Down
4 changes: 2 additions & 2 deletions testdata/primeText.golden
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ func PrimeString(s string) (Prime, error) {
if val, ok := _PrimeNameToValueMap[s]; ok {
return val, nil
}
s = strings.ToLower(s)
if val, ok := _PrimeNameToValueMap[s]; ok {

if val, ok := _PrimeNameToValueMap[strings.ToLower(s)]; ok {
return val, nil
}
return 0, fmt.Errorf("%s does not belong to Prime values", s)
Expand Down
4 changes: 2 additions & 2 deletions testdata/primeYaml.golden
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ func PrimeString(s string) (Prime, error) {
if val, ok := _PrimeNameToValueMap[s]; ok {
return val, nil
}
s = strings.ToLower(s)
if val, ok := _PrimeNameToValueMap[s]; ok {

if val, ok := _PrimeNameToValueMap[strings.ToLower(s)]; ok {
return val, nil
}
return 0, fmt.Errorf("%s does not belong to Prime values", s)
Expand Down
4 changes: 2 additions & 2 deletions testdata/trimPrefix.golden
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ func DayString(s string) (Day, error) {
if val, ok := _DayNameToValueMap[s]; ok {
return val, nil
}
s = strings.ToLower(s)
if val, ok := _DayNameToValueMap[s]; ok {

if val, ok := _DayNameToValueMap[strings.ToLower(s)]; ok {
return val, nil
}
return 0, fmt.Errorf("%s does not belong to Day values", s)
Expand Down
4 changes: 2 additions & 2 deletions testdata/trimPrefixMultiple.golden
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ func DayString(s string) (Day, error) {
if val, ok := _DayNameToValueMap[s]; ok {
return val, nil
}
s = strings.ToLower(s)
if val, ok := _DayNameToValueMap[s]; ok {

if val, ok := _DayNameToValueMap[strings.ToLower(s)]; ok {
return val, nil
}
return 0, fmt.Errorf("%s does not belong to Day values", s)
Expand Down
4 changes: 2 additions & 2 deletions testdata/unum.golden
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ func UnumString(s string) (Unum, error) {
if val, ok := _UnumNameToValueMap[s]; ok {
return val, nil
}
s = strings.ToLower(s)
if val, ok := _UnumNameToValueMap[s]; ok {

if val, ok := _UnumNameToValueMap[strings.ToLower(s)]; ok {
return val, nil
}
return 0, fmt.Errorf("%s does not belong to Unum values", s)
Expand Down

0 comments on commit 9d0b7d4

Please sign in to comment.