summaryrefslogtreecommitdiffstats
path: root/src/utils/utils.go
blob: ef381627113d48ab136dae60bc2646995447152c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package utils

import (
	"fmt"
	"math"

	ui "github.com/cjbassi/termui"
)

func BytesToKB(b uint64) float64 {
	return float64(b) / math.Pow10(3)
}

func BytesToMB(b uint64) float64 {
	return float64(b) / math.Pow10(6)
}

func BytesToGB(b uint64) float64 {
	return float64(b) / math.Pow10(9)
}

func Error(issue, diagnostics string) {
	ui.Close()
	fmt.Println("Error caught. Exiting program.")
	fmt.Println()
	fmt.Println("Issue with " + issue + ".")
	fmt.Println()
	fmt.Println("Diagnostics:\n" + diagnostics)
	fmt.Println()
	panic(1)
}