cleanup after 5a49bb8e88e070e43cbffaa68776259f11f6c053

This commit is contained in:
Aliaksandr Valialkin 2021-03-17 23:17:01 +02:00
parent 53fe52ac0e
commit 096d705076

View File

@ -236,17 +236,18 @@ func getMemStats(path string) (*memStats, error) {
// Extract key value.
line := strings.Fields(s)
if len(line) != 3 {
return nil, fmt.Errorf("cannot extract soft limit from %q", s)
return nil, fmt.Errorf("unexpected number of fields found in %q; got %d; want %d", s, len(line), 3)
}
memStatName := line[0]
memStatValue := line[1]
value, err := strconv.ParseUint(memStatValue, 10, 64)
if err != nil {
return nil, fmt.Errorf("cannot parse soft limit from %q: %s", s, err)
return nil, fmt.Errorf("cannot parse number from %q: %w", s, err)
}
if line[2] == "kB" {
value = value * 1024
if line[2] != "kB" {
return nil, fmt.Errorf("expecting kB value in %q; got %q", s, line[2])
}
value *= 1024
switch memStatName {
case "VmPeak:":
ms.vmPeak = value