Files
yt-dlp-bot/app/misc.go
2026-03-05 21:42:56 -05:00

27 lines
495 B
Go

package main
import (
"fmt"
"os"
)
var loading_emoji = os.Getenv("LOADING_EMOJI")
// 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)
}
}