moar refactor

This commit is contained in:
redanthrax 2022-06-17 09:38:18 -07:00
parent e3d5bf27a4
commit 1b9669f351
5 changed files with 126 additions and 136 deletions

View file

@ -238,21 +238,6 @@ func Unzip(src, dest string) error {
return nil
}
// https://yourbasic.org/golang/formatting-byte-size-to-human-readable-format/
func ByteCountSI(b uint64) string {
const unit = 1024
if b < unit {
return fmt.Sprintf("%d B", b)
}
div, exp := int64(unit), 0
for n := b / unit; n >= unit; n /= unit {
div *= unit
exp++
}
return fmt.Sprintf("%.1f %cB",
float64(b)/float64(div), "kMGTPE"[exp])
}
func randRange(min, max int) int {
rand.Seed(time.Now().UnixNano())
return rand.Intn(max-min) + min