@@ -63,34 +63,34 @@ func BytesSize(size float64) string {
6363
6464// FromHumanSize returns an integer from a human-readable specification of a
6565// size using SI standard (eg. "44kB", "17MB").
66- func FromHumanSize (size string ) (int64 , error ) {
66+ func FromHumanSize (size string ) (uint64 , error ) {
6767 return parseSize (size , decimalMap )
6868}
6969
7070// RAMInBytes parses a human-readable string representing an amount of RAM
7171// in bytes, kibibytes, mebibytes, gibibytes, or tebibytes and
72- // returns the number of bytes, or -1 if the string is unparseable .
72+ // returns the number of bytes.
7373// Units are case-insensitive, and the 'b' suffix is optional.
74- func RAMInBytes (size string ) (int64 , error ) {
74+ func RAMInBytes (size string ) (uint64 , error ) {
7575 return parseSize (size , binaryMap )
7676}
7777
7878// Parses the human-readable size string into the amount it represents.
79- func parseSize (sizeStr string , uMap unitMap ) (int64 , error ) {
79+ func parseSize (sizeStr string , uMap unitMap ) (uint64 , error ) {
8080 matches := sizeRegex .FindStringSubmatch (sizeStr )
8181 if len (matches ) != 4 {
82- return - 1 , fmt .Errorf ("invalid size: '%s'" , sizeStr )
82+ return 0 , fmt .Errorf ("invalid size: '%s'" , sizeStr )
8383 }
8484
8585 size , err := strconv .ParseFloat (matches [1 ], 64 )
8686 if err != nil {
87- return - 1 , err
87+ return 0 , err
8888 }
8989
9090 unitPrefix := strings .ToLower (matches [3 ])
9191 if mul , ok := uMap [unitPrefix ]; ok {
9292 size *= float64 (mul )
9393 }
9494
95- return int64 (size ), nil
95+ return uint64 (size ), nil
9696}
0 commit comments