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

Function formatBytes

pkg/console/progress_shared.go:6–15  ·  view source on GitHub ↗

formatBytes converts bytes to human-readable format (KB, MB, GB)

(bytes int64)

Source from the content-addressed store, hash-verified

4
5// formatBytes converts bytes to human-readable format (KB, MB, GB)
6func formatBytes(bytes int64) string {
7 value, unit := scaleBinaryBytes(bytes, []string{"KB", "MB", "GB"})
8 if unit == "B" {
9 return fmt.Sprintf("%dB", bytes)
10 }
11 if unit == "GB" {
12 return fmt.Sprintf("%.2fGB", value)
13 }
14 return fmt.Sprintf("%.1f%s", value, unit)
15}

Callers 3

UpdateMethod · 0.85
UpdateMethod · 0.85
TestFormatBytesFunction · 0.85

Calls 1

scaleBinaryBytesFunction · 0.85

Tested by 1

TestFormatBytesFunction · 0.68