CalculatePercentageInt safely calculates percentage from used and total int64 values Returns 0.0 if total is 0 to avoid division by zero.
(used, total int64)
| 159 | // CalculatePercentageInt safely calculates percentage from used and total int64 values |
| 160 | // Returns 0.0 if total is 0 to avoid division by zero. |
| 161 | func CalculatePercentageInt(used, total int64) float64 { |
| 162 | if total <= 0 { |
| 163 | return 0.0 |
| 164 | } |
| 165 | |
| 166 | return (float64(used) / float64(total)) * 100 |
| 167 | } |
| 168 | |
| 169 | // TrimTrailingWhitespace removes all trailing whitespace (spaces, tabs, newlines, carriage returns) from the end of the string. |
| 170 | func TrimTrailingWhitespace(s string) string { |