remove ginext/mongoext (no-dep lib)

This commit is contained in:
2022-10-27 16:07:42 +02:00
parent 568d7bd5e3
commit 47f123b86f
31 changed files with 6 additions and 123 deletions

16
langext/bytes.go Normal file
View File

@@ -0,0 +1,16 @@
package langext
import "fmt"
func FormatBytesToSI(b uint64) string {
const unit = 1000
if b < unit {
return fmt.Sprintf("%d B", b)
}
div, exp := uint64(unit), 0
for n := b / unit; n >= unit; n /= unit {
div *= unit
exp++
}
return fmt.Sprintf("%.1f %cB", float64(b)/float64(div), "kMGTPE"[exp])
}