Skip to content

Commit

Permalink
Merge pull request #38 from dmarkham/dan-fix-case-insensitive
Browse files Browse the repository at this point in the history
case insensitive bug fix
  • Loading branch information
dmarkham committed Aug 9, 2020
2 parents 0a1f0e6 + eb484e6 commit 67fb6ef
Show file tree
Hide file tree
Showing 20 changed files with 1,805 additions and 1,753 deletions.
3 changes: 1 addition & 2 deletions endtoend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ func TestEndToEnd(t *testing.T) {
// Generate, compile, and run the test programs.
for _, name := range names {
if !strings.HasSuffix(name, ".go") {
t.Errorf("%s is not a Go file", name)
continue
}
if name == "cgo.go" && !build.Default.CgoEnabled {
Expand Down Expand Up @@ -172,4 +171,4 @@ func runInDir(dir, name string, arg ...string) error {
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
return cmd.Run()
}
}
4 changes: 4 additions & 0 deletions enumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import "fmt"
const stringNameToValueMethod = `// %[1]sString retrieves an enum value from the enum constants string name.
// Throws an error if the param is not part of the enum.
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 {
return val, nil
}
Expand Down

0 comments on commit 67fb6ef

Please sign in to comment.