From ea7b8ea03f5c2222060afe435e907c1ab855a44b Mon Sep 17 00:00:00 2001 From: Francisco Carriedo Date: Mon, 21 Jul 2014 23:58:59 -0700 Subject: [PATCH] pkg/units: Better to not use `error` as var name Better to not use `error` as var name (might eclipse the error type) for clarity and to prevent subtle bugs. Docker-DCO-1.1-Signed-off-by: Francisco Carriedo (github: fcarriedo) --- pkg/units/size.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/pkg/units/size.go b/pkg/units/size.go index 1f77d607fe..e6e9f21b47 100644 --- a/pkg/units/size.go +++ b/pkg/units/size.go @@ -24,8 +24,8 @@ func HumanSize(size int64) string { // FromHumanSize returns an integer from a human-readable specification of a size // using SI standard (eg. "44kB", "17MB") func FromHumanSize(size string) (int64, error) { - re, error := regexp.Compile("^(\\d+)([kKmMgGtTpP])?[bB]?$") - if error != nil { + re, err := regexp.Compile("^(\\d+)([kKmMgGtTpP])?[bB]?$") + if err != nil { return -1, fmt.Errorf("%s does not specify not a size", size) } @@ -35,9 +35,9 @@ func FromHumanSize(size string) (int64, error) { return -1, fmt.Errorf("Invalid size: '%s'", size) } - theSize, error := strconv.ParseInt(matches[1], 10, 0) - if error != nil { - return -1, error + theSize, err := strconv.ParseInt(matches[1], 10, 0) + if err != nil { + return -1, err } unit := strings.ToLower(matches[2]) @@ -62,9 +62,9 @@ func FromHumanSize(size string) (int64, error) { // returns the number of bytes, or -1 if the string is unparseable. // Units are case-insensitive, and the 'b' suffix is optional. func RAMInBytes(size string) (int64, error) { - re, error := regexp.Compile("^(\\d+)([kKmMgGtT])?[bB]?$") - if error != nil { - return -1, error + re, err := regexp.Compile("^(\\d+)([kKmMgGtT])?[bB]?$") + if err != nil { + return -1, err } matches := re.FindStringSubmatch(size) @@ -73,9 +73,9 @@ func RAMInBytes(size string) (int64, error) { return -1, fmt.Errorf("Invalid size: '%s'", size) } - memLimit, error := strconv.ParseInt(matches[1], 10, 0) - if error != nil { - return -1, error + memLimit, err := strconv.ParseInt(matches[1], 10, 0) + if err != nil { + return -1, err } unit := strings.ToLower(matches[2])