MCPcopy Create free account
hub / github.com/github/gh-aw / FormatFileSize

Function FormatFileSize

pkg/console/format.go:21–32  ·  view source on GitHub ↗

FormatFileSize formats file sizes in a human-readable way (e.g., "1.2 KB", "3.4 MB")

(size int64)

Source from the content-addressed store, hash-verified

19
20// FormatFileSize formats file sizes in a human-readable way (e.g., "1.2 KB", "3.4 MB")
21func FormatFileSize(size int64) string {
22 if size == 0 {
23 return "0 B"
24 }
25
26 value, unit := scaleBinaryBytes(size, []string{"KB", "MB", "GB", "TB"})
27 if unit == "B" {
28 return fmt.Sprintf("%d B", size)
29 }
30
31 return fmt.Sprintf("%.1f %s", value, unit)
32}

Callers 12

TestFormatFileSizeFunction · 0.92
extractLogMetricsFunction · 0.92
FetchImportURLFunction · 0.92
displayStatsTableFunction · 0.92
writeWorkflowOutputMethod · 0.92
TestFormatFileSizeFunction · 0.85
applyFilesizeFormatFunction · 0.85

Calls 1

scaleBinaryBytesFunction · 0.85