Skip to content

Commit

Permalink
chore(crit): use camelCase for const
Browse files Browse the repository at this point in the history
The `countBytes()` utility was using SCREAMING_SNAKE_CASE for constants.
This has now been changed to use camelCase as per the Go convention.

Signed-off-by: Prajwal S N <[email protected]>
  • Loading branch information
snprajwal committed Aug 4, 2023
1 parent 4e55d6f commit 5963a51
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions crit/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ func ReadMagic(f *os.File) (string, error) {

// Helper to convert bytes into a more readable unit
func countBytes(n int64) string {
const UNIT int64 = 1024
if n < UNIT {
const unit int64 = 1024
if n < unit {
return fmt.Sprint(n, " B")
}
div, exp := UNIT, 0
for i := n / UNIT; i >= UNIT; i /= UNIT {
div *= UNIT
div, exp := unit, 0
for i := n / unit; i >= unit; i /= unit {
div *= unit
exp++
}
return fmt.Sprintf("%.1f %cB", float64(n)/float64(div), "KMGTPE"[exp])
Expand Down Expand Up @@ -152,7 +152,7 @@ func getRegFilePath(dir string, file *fdinfo.FileEntry, fID uint32) (string, err
if file.GetReg() != nil {
return file.GetReg().GetName(), nil
}
return "Unknown path", nil
return "unknown", nil
}

if regImg == nil {
Expand All @@ -168,7 +168,7 @@ func getRegFilePath(dir string, file *fdinfo.FileEntry, fID uint32) (string, err
}
}

return "Unknown path", nil
return "unknown", nil
}

// Helper to get file path of pipe files
Expand Down

0 comments on commit 5963a51

Please sign in to comment.