package cobol import ( "fmt" ) // returns a human readable string of the bytes func Bytes(anInt any) string { return "todo" } // returns a human readable string of the bytes // also returns the error if there was one func BytesCheck(anInt any) (string, error) { return "todo", NoBytes } // returns an int. will try to convert strings func GetBytes(anInt any) (int, error) { return 0, NoBytes } // This isn't for the marketing department // so this isn't going to use 'MiB' and 'GiB' func HumanFormatBytes(b int) string { if b < 2000 { return fmt.Sprintf("%d B", b) } kb := int(b / 1024) if kb < 2000 { return fmt.Sprintf("%d KB", kb) } mb := int(b / (1024 * 1024)) if mb < 2000 { return fmt.Sprintf("%d MB", mb) } gb := int(b / (1024 * 1024 * 1024)) if gb < 2000 { return fmt.Sprintf("%d GB", gb) } tb := int(b / (1024 * 1024 * 1024 * 1024)) return fmt.Sprintf("%d TB", tb) }