Add ability to browse data
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func createDeviceLink(deviceType, name string, qr *int) CreateDeviceLink {
|
||||
return CreateDeviceLink{
|
||||
Type: deviceType,
|
||||
@@ -13,3 +17,31 @@ type CreateDeviceLink struct {
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user