Skip to content

Commit

Permalink
fixed cutprefix - lets make old go happy
Browse files Browse the repository at this point in the history
  • Loading branch information
adubovikov committed Aug 31, 2023
1 parent ed29af0 commit 8872462
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions hep.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func (h *HEP) parse(packet []byte) error {

h.Timestamp = time.Unix(int64(h.Tsec), int64(h.Tmsec*1000))
if h.Tsec == 0 && h.Tmsec == 0 {
log.Println("Debug> got null timestamp from nodeID %d", h.NodeID)
log.Println("Debug> got null timestamp from nodeID: ", h.NodeID)
h.Timestamp = time.Now()
}

Expand Down Expand Up @@ -413,21 +413,20 @@ func Human2FileSize(size string) (int64, error) {
}

if strings.HasSuffix(size, suffix) {
dataBytes, ok := strings.CutSuffix(size, suffix)
if ok {
baseVar, err := strconv.Atoi(dataBytes)
if err != nil {
return 0, err
} else {
bytesSize = int64(math.Pow(float64(baseVar), float64(i)))
return bytesSize, nil
}
dataBytes := strings.TrimPrefix(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
}
}
}

dataBytes, ok := strings.CutSuffix(size, "B")
if ok {
if strings.HasSuffix(size, "B") {

dataBytes := strings.TrimPrefix(size, "B")
baseVar, err := strconv.Atoi(dataBytes)
if err != nil {
return 0, err
Expand Down

0 comments on commit 8872462

Please sign in to comment.