diff --git a/units/size.go b/units/size.go index d8410b4..4a953fb 100644 --- a/units/size.go +++ b/units/size.go @@ -63,7 +63,7 @@ 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, err := regexp.Compile("^(\\d+)([kKmMgGtT])?[bB]?$") + re, err := regexp.Compile("^(\\d+)([kKmMgGtTpP])?[bB]?$") if err != nil { return -1, err } @@ -90,6 +90,8 @@ func RAMInBytes(size string) (int64, error) { memLimit *= 1024 * 1024 * 1024 case "t": memLimit *= 1024 * 1024 * 1024 * 1024 + case "p": + memLimit *= 1024 * 1024 * 1024 * 1024 * 1024 } return memLimit, nil diff --git a/units/size_test.go b/units/size_test.go index de8b44f..a2dfedc 100644 --- a/units/size_test.go +++ b/units/size_test.go @@ -64,7 +64,11 @@ func TestRAMInBytes(t *testing.T) { assertRAMInBytes(t, "32MB", false, 32*1024*1024) assertRAMInBytes(t, "32Gb", false, 32*1024*1024*1024) assertRAMInBytes(t, "32G", false, 32*1024*1024*1024) + assertRAMInBytes(t, "32GB", false, 32*1024*1024*1024) assertRAMInBytes(t, "32Tb", false, 32*1024*1024*1024*1024) + assertRAMInBytes(t, "8Pb", false, 8*1024*1024*1024*1024*1024) + assertRAMInBytes(t, "8PB", false, 8*1024*1024*1024*1024*1024) + assertRAMInBytes(t, "8P", false, 8*1024*1024*1024*1024*1024) assertRAMInBytes(t, "", true, -1) assertRAMInBytes(t, "hello", true, -1)