Compare commits
3 Commits
f720d613e7
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 05519694e1 | |||
| 78e6de32d7 | |||
| 24904dde66 |
@@ -21,6 +21,7 @@ const VM InstanceType = "VM"
|
|||||||
const CT InstanceType = "CT"
|
const CT InstanceType = "CT"
|
||||||
|
|
||||||
type Instance struct {
|
type Instance struct {
|
||||||
|
VMID InstanceID `json:"vmid" mapstructure:"vmid"`
|
||||||
Type InstanceType `json:"type" mapstructure:"type"`
|
Type InstanceType `json:"type" mapstructure:"type"`
|
||||||
Name string `json:"name" mapstructure:"name"`
|
Name string `json:"name" mapstructure:"name"`
|
||||||
Proctype string `json:"cpu" mapstructure:"cpu"`
|
Proctype string `json:"cpu" mapstructure:"cpu"`
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ func FormatNumber(val uint64, base uint64) (string, string) {
|
|||||||
valf := float64(val)
|
valf := float64(val)
|
||||||
basef := float64(base)
|
basef := float64(base)
|
||||||
steps := 0
|
steps := 0
|
||||||
for math.Abs(valf) > basef && steps < len(prefixes) {
|
for math.Abs(valf) > basef && steps < len(prefixes)-1 {
|
||||||
valf /= basef
|
valf /= basef
|
||||||
steps++
|
steps++
|
||||||
}
|
}
|
||||||
@@ -48,7 +48,7 @@ func FormatNumber(val uint64, base uint64) (string, string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Converts int, int32, and int64 to uint64. Less than 0 check.
|
// Converts int, int32, and int64 to uint64. Less than 0 check.
|
||||||
func SafeUint64[I int | int32 | int64](i I) uint64 {
|
func SafeUint64[I int | int32 | int64 | uint | uint32](i I) uint64 {
|
||||||
if i < 0 {
|
if i < 0 {
|
||||||
log.Printf("Tried to cast %d to uint64", i)
|
log.Printf("Tried to cast %d to uint64", i)
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
Reference in New Issue
Block a user