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