MCPcopy Index your code
hub / github.com/docker/docker-agent / formatBytes

Function formatBytes

pkg/app/transcript/transcript.go:90–101  ·  view source on GitHub ↗

formatBytes returns a human-readable byte size string (e.g. "1.2 MB").

(b int64)

Source from the content-addressed store, hash-verified

88
89// formatBytes returns a human-readable byte size string (e.g. "1.2 MB").
90func formatBytes(b int64) string {
91 const unit = 1024
92 if b < unit {
93 return fmt.Sprintf("%d B", b)
94 }
95 div, exp := int64(unit), 0
96 for n := b / unit; n >= unit; n /= unit {
97 div *= unit
98 exp++
99 }
100 return fmt.Sprintf("%.1f %cB", float64(b)/float64(div), "KMGTPE"[exp])
101}
102
103func writeAssistantMessage(builder *strings.Builder, msg session.Message) {
104 builder.WriteString("\n## Assistant")

Callers 2

TestFormatBytesFunction · 0.85
writeUserMessageFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestFormatBytesFunction · 0.68