2018-02-18 23:25:02 -08:00
|
|
|
package utils
|
|
|
|
|
|
|
|
import (
|
2018-04-10 20:08:02 -07:00
|
|
|
"fmt"
|
2018-02-18 23:25:02 -08:00
|
|
|
"math"
|
2018-04-10 20:08:02 -07:00
|
|
|
|
|
|
|
ui "github.com/cjbassi/termui"
|
2018-02-18 23:25:02 -08:00
|
|
|
)
|
|
|
|
|
2018-02-22 23:58:48 -08:00
|
|
|
func BytesToKB(b uint64) float64 {
|
|
|
|
return float64(b) / math.Pow10(3)
|
2018-02-18 23:25:02 -08:00
|
|
|
}
|
|
|
|
|
2018-02-22 23:58:48 -08:00
|
|
|
func BytesToMB(b uint64) float64 {
|
|
|
|
return float64(b) / math.Pow10(6)
|
2018-02-18 23:25:02 -08:00
|
|
|
}
|
|
|
|
|
2018-02-22 23:58:48 -08:00
|
|
|
func BytesToGB(b uint64) float64 {
|
|
|
|
return float64(b) / math.Pow10(9)
|
2018-02-18 23:25:02 -08:00
|
|
|
}
|
2018-04-10 20:08:02 -07:00
|
|
|
|
|
|
|
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)
|
|
|
|
}
|