diff --git a/units.go b/units.go index 1a218f2..59029d1 100644 --- a/units.go +++ b/units.go @@ -2,6 +2,7 @@ package proxmoxaas_common_lib import ( "fmt" + "log" "math" "strings" ) @@ -48,3 +49,11 @@ func FormatNumber(val uint64, base uint64) (string, string) { return "0", "" } } + +func SafeUint64(i int) uint64 { + if i < 0 { + log.Printf("Tried to cast %d to uint64", i) + return 0 + } + return uint64(i) +}