"src/targets/vscode:/vscode.git/clone" did not exist on "a00d8b5f473ba98f1cb766641e96c4692a6a18b3"
bytes.go 313 Bytes
Newer Older
Michael Yang's avatar
Michael Yang committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
package format

import "fmt"

func HumanBytes(b int64) string {
	switch {
	case b > 1000*1000*1000:
		return fmt.Sprintf("%d GB", b/1000/1000/1000)
	case b > 1000*1000:
		return fmt.Sprintf("%d MB", b/1000/1000)
	case b > 1000:
		return fmt.Sprintf("%d KB", b/1000)
	default:
		return fmt.Sprintf("%d B", b)
	}
}