MCPcopy Index your code
hub / github.com/TruthHun/BookStack / FormatBytes

Function FormatBytes

utils/file.go:60–72  ·  view source on GitHub ↗
(size int64)

Source from the content-addressed store, hash-verified

58}
59
60func FormatBytes(size int64) string {
61 units := []string{" B", " KB", " MB", " GB", " TB"}
62
63 s := float64(size)
64
65 i := 0
66
67 for ; s >= 1024 && i < 4; i++ {
68 s /= 1024
69 }
70
71 return fmt.Sprintf("%.2f%s", s, units[i])
72}
73
74func Round(val float64, places int) float64 {
75 var t float64

Callers 2

FindMethod · 0.92
FindToPagerMethod · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected