|
for _, unitRegex := range HintedRegex[""] { |
If there are no hints, and if more than one regexes match, then it is ambiguous, and you should return the names of both matching regexes. To accommodate, define an error type:
type ErrAmbiguousUnit []string
func (e ErrAmbigousUnit) Error() string {
return "Ambiguous unit:"+strings.Join([]string(e),", ")
}
and return (string,string,error) from the parse function.
units/units.go
Line 47 in 93725cf
If there are no hints, and if more than one regexes match, then it is ambiguous, and you should return the names of both matching regexes. To accommodate, define an error type:
and return (string,string,error) from the parse function.