refactor: round up ram to 2 decimals

This commit is contained in:
nekohepott 2026-06-17 04:16:36 +03:00
parent 2ddc276257
commit dff0a8ca47
No known key found for this signature in database

View File

@ -48,9 +48,9 @@ func GetDist() (string, string) {
func getSizeRam(total, avaible, used *int) string { func getSizeRam(total, avaible, used *int) string {
if *total >= 1024*1024 && *avaible >= 1024*1024 { if *total >= 1024*1024 && *avaible >= 1024*1024 {
*used = *total - *avaible *used = *total - *avaible
usedGiB := *used / (1024 * 1024) usedGiB := float64(*used) / (1024 * 1024)
totalGiB := *total / (1024 * 1024) totalGiB := float64(*total) / (1024 * 1024)
ram := fmt.Sprintf("%d / %d Gi", usedGiB, totalGiB) ram := fmt.Sprintf("%.2f / %.2f GiB", usedGiB, totalGiB)
ram = strings.TrimSpace(ram) ram = strings.TrimSpace(ram)
return ram return ram