Represent -1 as "off" for SIZE values

This commit is contained in:
Nick Craig-Wood
2016-06-03 21:51:39 +01:00
parent 5723d788a4
commit e818b7c206
2 changed files with 10 additions and 0 deletions
+6
View File
@@ -102,6 +102,8 @@ func (x SizeSuffix) String() string {
scaled := float64(0)
suffix := ""
switch {
case x < 0:
return "off"
case x == 0:
return "0"
case x < 1024:
@@ -128,6 +130,10 @@ func (x *SizeSuffix) Set(s string) error {
if len(s) == 0 {
return fmt.Errorf("Empty string")
}
if strings.ToLower(s) == "off" {
*x = -1
return nil
}
suffix := s[len(s)-1]
suffixLen := 1
var multiplier float64