Skip to content

Commit

Permalink
fixed trimsuffix
Browse files Browse the repository at this point in the history
  • Loading branch information
adubovikov committed Aug 31, 2023
1 parent 8872462 commit 59df411
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion HFP.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
8 changes: 4 additions & 4 deletions hep.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 59df411

Please sign in to comment.