48 lines
740 B
Go
48 lines
740 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
)
|
|
|
|
func createDeviceLink(deviceType, name string, qr *int) CreateDeviceLink {
|
|
return CreateDeviceLink{
|
|
Type: deviceType,
|
|
Name: name,
|
|
Qr: qr,
|
|
}
|
|
}
|
|
|
|
type CreateDeviceLink struct {
|
|
Type string
|
|
Name string
|
|
Qr *int
|
|
}
|
|
|
|
func formatMemorySize(size int) string {
|
|
const (
|
|
KB = 1024
|
|
MB = KB * 1024
|
|
GB = MB * 1024
|
|
)
|
|
|
|
switch {
|
|
case size >= GB:
|
|
return fmt.Sprintf("%.2f GB", float64(size)/GB)
|
|
case size >= MB:
|
|
return fmt.Sprintf("%.2f MB", float64(size)/MB)
|
|
case size >= KB:
|
|
return fmt.Sprintf("%.2f KB", float64(size)/KB)
|
|
default:
|
|
return fmt.Sprintf("%d B", size)
|
|
}
|
|
}
|
|
|
|
func formatType(t string) string {
|
|
switch t {
|
|
case "ram":
|
|
return "Random Access Memory"
|
|
default:
|
|
return t
|
|
}
|
|
}
|