add SafeUint64 to units
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user