From 59df411926279a0824dd0be630ced28c3be190ee Mon Sep 17 00:00:00 2001 From: Alexandr Dubovikov Date: Thu, 31 Aug 2023 12:39:59 +0200 Subject: [PATCH] fixed trimsuffix --- HFP.go | 2 +- hep.go | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/HFP.go b/HFP.go index 49e34a5..9ea6661 100644 --- a/HFP.go +++ b/HFP.go @@ -14,7 +14,7 @@ import ( "github.com/guumaster/logsymbols" ) -const AppVersion = "0.55.5" +const AppVersion = "0.55.6" var localAddr *string = flag.String("l", ":9060", "Local HEP listening address") var remoteAddr *string = flag.String("r", "192.168.2.2:9060", "Remote HEP address") diff --git a/hep.go b/hep.go index 241e01e..8c7d683 100644 --- a/hep.go +++ b/hep.go @@ -413,20 +413,20 @@ func Human2FileSize(size string) (int64, error) { } if strings.HasSuffix(size, suffix) { - dataBytes := strings.TrimPrefix(size, suffix) + dataBytes := strings.TrimSuffix(size, suffix) baseVar, err := strconv.Atoi(dataBytes) if err != nil { return 0, err } else { - bytesSize = int64(math.Pow(float64(baseVar), float64(i))) - return bytesSize, nil + bytesSize = int64(math.Pow(float64(1024), float64(i))) * int64(baseVar) + return int64(bytesSize), nil } } } if strings.HasSuffix(size, "B") { - dataBytes := strings.TrimPrefix(size, "B") + dataBytes := strings.TrimSuffix(size, "B") baseVar, err := strconv.Atoi(dataBytes) if err != nil { return 0, err