Skip to content
Snippets Groups Projects
Commit f88246b5 authored by Gabriel Zachmann's avatar Gabriel Zachmann
Browse files

define a constant instead of duplicating literal

parent ccfc73c7
No related branches found
No related tags found
No related merge requests found
......@@ -38,6 +38,8 @@ func NewGrantType(s string) GrantType {
return -1
}
const valueNotValidFmt = "value '%s' not valid for GrantType"
func (g *GrantType) String() string {
if *g < 0 || int(*g) >= len(AllGrantTypes) {
return ""
......@@ -58,7 +60,7 @@ func (g *GrantType) UnmarshalYAML(value *yaml.Node) error {
}
*g = NewGrantType(s)
if !g.Valid() {
return errors.Errorf("value '%s' not valid for GrantType", s)
return errors.Errorf(valueNotValidFmt, s)
}
return nil
}
......@@ -71,7 +73,7 @@ func (g *GrantType) UnmarshalJSON(data []byte) error {
}
*g = NewGrantType(s)
if !g.Valid() {
return errors.Errorf("value '%s' not valid for GrantType", s)
return errors.Errorf(valueNotValidFmt, s)
}
return nil
}
......@@ -81,7 +83,7 @@ func (g *GrantType) UnmarshalText(data []byte) error {
s := string(data)
*g = NewGrantType(s)
if !g.Valid() {
return errors.Errorf("value '%s' not valid for GrantType", s)
return errors.Errorf(valueNotValidFmt, s)
}
return nil
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment