forked from mirror/enumer
Merge pull request #44 from dmarkham/dan/issue-43
Return the same string passed for error
This commit is contained in:
commit
9d0b7d4c67
|
@ -4,8 +4,8 @@ matrix:
|
||||||
allow_failures:
|
allow_failures:
|
||||||
- go: master
|
- go: master
|
||||||
include:
|
include:
|
||||||
- go: 1.14.x
|
|
||||||
- go: 1.15.x
|
- go: 1.15.x
|
||||||
|
- go: 1.16.x
|
||||||
- go: master
|
- go: master
|
||||||
env:
|
env:
|
||||||
global:
|
global:
|
||||||
|
@ -24,6 +24,6 @@ deploy:
|
||||||
- cli/build/enumer.windows-amd64.exe.tar.gz
|
- cli/build/enumer.windows-amd64.exe.tar.gz
|
||||||
- cli/build/sha256sum.txt
|
- cli/build/sha256sum.txt
|
||||||
on:
|
on:
|
||||||
go: 1.15.x
|
go: 1.16.x
|
||||||
repo: dmarkham/enumer
|
repo: dmarkham/enumer
|
||||||
tags: true
|
tags: true
|
||||||
|
|
|
@ -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).
|
Enumer is a tool to generate Go code that adds useful methods to Go enums (constants with a specific type).
|
||||||
|
|
|
@ -10,8 +10,8 @@ func %[1]sString(s string) (%[1]s, error) {
|
||||||
if val, ok := _%[1]sNameToValueMap[s]; ok {
|
if val, ok := _%[1]sNameToValueMap[s]; ok {
|
||||||
return val, nil
|
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 val, nil
|
||||||
}
|
}
|
||||||
return 0, fmt.Errorf("%%s does not belong to %[1]s values", s)
|
return 0, fmt.Errorf("%%s does not belong to %[1]s values", s)
|
||||||
|
|
|
@ -60,8 +60,8 @@ func DayString(s string) (Day, error) {
|
||||||
if val, ok := _DayNameToValueMap[s]; ok {
|
if val, ok := _DayNameToValueMap[s]; ok {
|
||||||
return val, nil
|
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 val, nil
|
||||||
}
|
}
|
||||||
return 0, fmt.Errorf("%s does not belong to Day values", s)
|
return 0, fmt.Errorf("%s does not belong to Day values", s)
|
||||||
|
|
|
@ -60,8 +60,8 @@ func DayString(s string) (Day, error) {
|
||||||
if val, ok := _DayNameToValueMap[s]; ok {
|
if val, ok := _DayNameToValueMap[s]; ok {
|
||||||
return val, nil
|
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 val, nil
|
||||||
}
|
}
|
||||||
return 0, fmt.Errorf("%s does not belong to Day values", s)
|
return 0, fmt.Errorf("%s does not belong to Day values", s)
|
||||||
|
|
|
@ -60,8 +60,8 @@ func DayString(s string) (Day, error) {
|
||||||
if val, ok := _DayNameToValueMap[s]; ok {
|
if val, ok := _DayNameToValueMap[s]; ok {
|
||||||
return val, nil
|
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 val, nil
|
||||||
}
|
}
|
||||||
return 0, fmt.Errorf("%s does not belong to Day values", s)
|
return 0, fmt.Errorf("%s does not belong to Day values", s)
|
||||||
|
|
|
@ -60,8 +60,8 @@ func DayString(s string) (Day, error) {
|
||||||
if val, ok := _DayNameToValueMap[s]; ok {
|
if val, ok := _DayNameToValueMap[s]; ok {
|
||||||
return val, nil
|
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 val, nil
|
||||||
}
|
}
|
||||||
return 0, fmt.Errorf("%s does not belong to Day values", s)
|
return 0, fmt.Errorf("%s does not belong to Day values", s)
|
||||||
|
|
|
@ -81,8 +81,8 @@ func GapString(s string) (Gap, error) {
|
||||||
if val, ok := _GapNameToValueMap[s]; ok {
|
if val, ok := _GapNameToValueMap[s]; ok {
|
||||||
return val, nil
|
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 val, nil
|
||||||
}
|
}
|
||||||
return 0, fmt.Errorf("%s does not belong to Gap values", s)
|
return 0, fmt.Errorf("%s does not belong to Gap values", s)
|
||||||
|
|
|
@ -53,8 +53,8 @@ func NumString(s string) (Num, error) {
|
||||||
if val, ok := _NumNameToValueMap[s]; ok {
|
if val, ok := _NumNameToValueMap[s]; ok {
|
||||||
return val, nil
|
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 val, nil
|
||||||
}
|
}
|
||||||
return 0, fmt.Errorf("%s does not belong to Num values", s)
|
return 0, fmt.Errorf("%s does not belong to Num values", s)
|
||||||
|
|
|
@ -45,8 +45,8 @@ func NumberString(s string) (Number, error) {
|
||||||
if val, ok := _NumberNameToValueMap[s]; ok {
|
if val, ok := _NumberNameToValueMap[s]; ok {
|
||||||
return val, nil
|
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 val, nil
|
||||||
}
|
}
|
||||||
return 0, fmt.Errorf("%s does not belong to Number values", s)
|
return 0, fmt.Errorf("%s does not belong to Number values", s)
|
||||||
|
|
|
@ -97,8 +97,8 @@ func PrimeString(s string) (Prime, error) {
|
||||||
if val, ok := _PrimeNameToValueMap[s]; ok {
|
if val, ok := _PrimeNameToValueMap[s]; ok {
|
||||||
return val, nil
|
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 val, nil
|
||||||
}
|
}
|
||||||
return 0, fmt.Errorf("%s does not belong to Prime values", s)
|
return 0, fmt.Errorf("%s does not belong to Prime values", s)
|
||||||
|
|
|
@ -97,8 +97,8 @@ func PrimeString(s string) (Prime, error) {
|
||||||
if val, ok := _PrimeNameToValueMap[s]; ok {
|
if val, ok := _PrimeNameToValueMap[s]; ok {
|
||||||
return val, nil
|
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 val, nil
|
||||||
}
|
}
|
||||||
return 0, fmt.Errorf("%s does not belong to Prime values", s)
|
return 0, fmt.Errorf("%s does not belong to Prime values", s)
|
||||||
|
|
|
@ -97,8 +97,8 @@ func PrimeString(s string) (Prime, error) {
|
||||||
if val, ok := _PrimeNameToValueMap[s]; ok {
|
if val, ok := _PrimeNameToValueMap[s]; ok {
|
||||||
return val, nil
|
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 val, nil
|
||||||
}
|
}
|
||||||
return 0, fmt.Errorf("%s does not belong to Prime values", s)
|
return 0, fmt.Errorf("%s does not belong to Prime values", s)
|
||||||
|
|
|
@ -97,8 +97,8 @@ func PrimeString(s string) (Prime, error) {
|
||||||
if val, ok := _PrimeNameToValueMap[s]; ok {
|
if val, ok := _PrimeNameToValueMap[s]; ok {
|
||||||
return val, nil
|
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 val, nil
|
||||||
}
|
}
|
||||||
return 0, fmt.Errorf("%s does not belong to Prime values", s)
|
return 0, fmt.Errorf("%s does not belong to Prime values", s)
|
||||||
|
|
|
@ -97,8 +97,8 @@ func PrimeString(s string) (Prime, error) {
|
||||||
if val, ok := _PrimeNameToValueMap[s]; ok {
|
if val, ok := _PrimeNameToValueMap[s]; ok {
|
||||||
return val, nil
|
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 val, nil
|
||||||
}
|
}
|
||||||
return 0, fmt.Errorf("%s does not belong to Prime values", s)
|
return 0, fmt.Errorf("%s does not belong to Prime values", s)
|
||||||
|
|
|
@ -97,8 +97,8 @@ func PrimeString(s string) (Prime, error) {
|
||||||
if val, ok := _PrimeNameToValueMap[s]; ok {
|
if val, ok := _PrimeNameToValueMap[s]; ok {
|
||||||
return val, nil
|
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 val, nil
|
||||||
}
|
}
|
||||||
return 0, fmt.Errorf("%s does not belong to Prime values", s)
|
return 0, fmt.Errorf("%s does not belong to Prime values", s)
|
||||||
|
|
|
@ -97,8 +97,8 @@ func PrimeString(s string) (Prime, error) {
|
||||||
if val, ok := _PrimeNameToValueMap[s]; ok {
|
if val, ok := _PrimeNameToValueMap[s]; ok {
|
||||||
return val, nil
|
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 val, nil
|
||||||
}
|
}
|
||||||
return 0, fmt.Errorf("%s does not belong to Prime values", s)
|
return 0, fmt.Errorf("%s does not belong to Prime values", s)
|
||||||
|
|
|
@ -60,8 +60,8 @@ func DayString(s string) (Day, error) {
|
||||||
if val, ok := _DayNameToValueMap[s]; ok {
|
if val, ok := _DayNameToValueMap[s]; ok {
|
||||||
return val, nil
|
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 val, nil
|
||||||
}
|
}
|
||||||
return 0, fmt.Errorf("%s does not belong to Day values", s)
|
return 0, fmt.Errorf("%s does not belong to Day values", s)
|
||||||
|
|
|
@ -60,8 +60,8 @@ func DayString(s string) (Day, error) {
|
||||||
if val, ok := _DayNameToValueMap[s]; ok {
|
if val, ok := _DayNameToValueMap[s]; ok {
|
||||||
return val, nil
|
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 val, nil
|
||||||
}
|
}
|
||||||
return 0, fmt.Errorf("%s does not belong to Day values", s)
|
return 0, fmt.Errorf("%s does not belong to Day values", s)
|
||||||
|
|
|
@ -63,8 +63,8 @@ func UnumString(s string) (Unum, error) {
|
||||||
if val, ok := _UnumNameToValueMap[s]; ok {
|
if val, ok := _UnumNameToValueMap[s]; ok {
|
||||||
return val, nil
|
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 val, nil
|
||||||
}
|
}
|
||||||
return 0, fmt.Errorf("%s does not belong to Unum values", s)
|
return 0, fmt.Errorf("%s does not belong to Unum values", s)
|
||||||
|
|
Loading…
Reference in New Issue