MCPcopy Create free account
hub / github.com/devnullvoid/pvetui / getString

Function getString

pkg/api/utils.go:24–32  ·  view source on GitHub ↗

Helper functions to extract values from interface{} maps safely getString safely extracts a string value from a map[string]interface{}. This function handles the common pattern of extracting string values from JSON-decoded maps where the value type is interface{}. It performs safe type assertion an

(data map[string]interface{}, key string)

Source from the content-addressed store, hash-verified

22//
23// Returns the string value or empty string if not found or wrong type.
24func getString(data map[string]interface{}, key string) string {
25 if val, ok := data[key]; ok {
26 if str, ok := val.(string); ok {
27 return str
28 }
29 }
30
31 return ""
32}
33
34// getFloat safely extracts a numeric value from a map[string]interface{} as float64.
35//

Callers 12

GetStorageContentMethod · 0.85
GetAvailableTemplatesMethod · 0.85
GetNodeStatusMethod · 0.85
GetNodeStoragesMethod · 0.85
GetNodeDisksMethod · 0.85
GetNodeDiskSmartMethod · 0.85
GetNodeUpdatesMethod · 0.85
GetSnapshotsMethod · 0.85
getClusterBasicStatusMethod · 0.85
GetTaskStatusMethod · 0.85
GetBackupsMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected