FormatBytesFloat converts float64 GB values to human-readable format Input is assumed to be in GB, converts to appropriate units with 2 decimal places.
(gb float64)
| 63 | // FormatBytesFloat converts float64 GB values to human-readable format |
| 64 | // Input is assumed to be in GB, converts to appropriate units with 2 decimal places. |
| 65 | func FormatBytesFloat(gb float64) string { |
| 66 | const ( |
| 67 | TbInGb = 1024 |
| 68 | PbInGb = 1024 * 1024 |
| 69 | ) |
| 70 | |
| 71 | switch { |
| 72 | case gb >= PbInGb: |
| 73 | return fmt.Sprintf("%.2f PB", gb/PbInGb) |
| 74 | case gb >= TbInGb: |
| 75 | return fmt.Sprintf("%.2f TB", gb/TbInGb) |
| 76 | default: |
| 77 | return fmt.Sprintf("%.2f GB", gb) |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | // FormatStatusIndicator returns a string with a colored status indicator. |
| 82 | // Uses theme-aware color tags. |