Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
| ... | ... |
@@ -10,6 +10,7 @@ import ( |
| 10 | 10 |
// See: http://en.wikipedia.org/wiki/Binary_prefix |
| 11 | 11 |
const ( |
| 12 | 12 |
// Decimal |
| 13 |
+ |
|
| 13 | 14 |
KB = 1000 |
| 14 | 15 |
MB = 1000 * KB |
| 15 | 16 |
GB = 1000 * MB |
| ... | ... |
@@ -17,6 +18,7 @@ const ( |
| 17 | 17 |
PB = 1000 * TB |
| 18 | 18 |
|
| 19 | 19 |
// Binary |
| 20 |
+ |
|
| 20 | 21 |
KiB = 1024 |
| 21 | 22 |
MiB = 1024 * KiB |
| 22 | 23 |
GiB = 1024 * MiB |
| ... | ... |
@@ -52,7 +54,7 @@ func FromHumanSize(size string) (int64, error) {
|
| 52 | 52 |
return parseSize(size, decimalMap) |
| 53 | 53 |
} |
| 54 | 54 |
|
| 55 |
-// Parses a human-readable string representing an amount of RAM |
|
| 55 |
+// RAMInBytes parses a human-readable string representing an amount of RAM |
|
| 56 | 56 |
// in bytes, kibibytes, mebibytes, gibibytes, or tebibytes and |
| 57 | 57 |
// returns the number of bytes, or -1 if the string is unparseable. |
| 58 | 58 |
// Units are case-insensitive, and the 'b' suffix is optional. |
| ... | ... |
@@ -64,7 +66,7 @@ func RAMInBytes(size string) (int64, error) {
|
| 64 | 64 |
func parseSize(sizeStr string, uMap unitMap) (int64, error) {
|
| 65 | 65 |
matches := sizeRegex.FindStringSubmatch(sizeStr) |
| 66 | 66 |
if len(matches) != 3 {
|
| 67 |
- return -1, fmt.Errorf("Invalid size: '%s'", sizeStr)
|
|
| 67 |
+ return -1, fmt.Errorf("invalid size: '%s'", sizeStr)
|
|
| 68 | 68 |
} |
| 69 | 69 |
|
| 70 | 70 |
size, err := strconv.ParseInt(matches[1], 10, 0) |