Files
yt-dlp-bot/app/misc.go

22 lines
436 B
Go

package main
import "fmt"
// Helper function to create string pointer
func ptr(s string) *string {
return &s
}
func formatBytes(b int) string {
switch {
case b >= 1<<30:
return fmt.Sprintf("%.1f GB", float64(b)/float64(1<<30))
case b >= 1<<20:
return fmt.Sprintf("%.1f MB", float64(b)/float64(1<<20))
case b >= 1<<10:
return fmt.Sprintf("%.1f KB", float64(b)/float64(1<<10))
default:
return fmt.Sprintf("%d B", b)
}
}