From 41a06f6b454761908e9d7710f25bbf3e409b516e Mon Sep 17 00:00:00 2001 From: Arthur Lu Date: Fri, 26 Jun 2026 20:31:56 +0000 Subject: [PATCH] add SafeUint64 to units --- units.go | 9 +++++++++ 1 file changed, 9 insertions(+) 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) +}