xmtop/utils/utils.go

32 lines
537 B
Go
Raw Normal View History

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