-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodifier.go
46 lines (41 loc) · 897 Bytes
/
modifier.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package comver
type modifier int8
const (
modifierPatch modifier = 10
modifierStable modifier = 0
modifierRC modifier = -10
modifierBeta modifier = -20
modifierAlpha modifier = -30
errUnexpectedModifier stringError = "unexpected modifier"
)
func newModifier(s string) (modifier, error) {
switch s {
case "":
return modifierStable, nil
case "patch", "pl", "p":
return modifierPatch, nil
case "rc":
return modifierRC, nil
case "beta", "b":
return modifierBeta, nil
case "alpha", "a":
return modifierAlpha, nil
}
return modifierStable, errUnexpectedModifier
}
func (s modifier) String() string {
switch s {
case modifierPatch:
return "patch"
case modifierRC:
return "RC"
case modifierBeta:
return "beta"
case modifierAlpha:
return "alpha"
case modifierStable:
return ""
default:
return ""
}
}