Author: Paolo Lulli <paolo@lulli.net>
Treat timestamp as any
client/main.go | 17 +++++++++--------
diff --git a/client/main.go b/client/main.go index 555934dd30787721332b1ed706095f22bd17f41e..2546b4ac7319925a5a8084336f01243a23ddc359 100644 --- a/client/main.go +++ b/client/main.go @@ -232,7 +232,12 @@ if errNoValue { return } + var keys []string for k := range dataMap { + keys = append(keys, k) + } + + for _, k := range keys { fmt.Printf("\"%v\"%s", k, recordSeparator) } fmt.Printf("%s", rowSeparator) @@ -241,12 +246,8 @@ rowMap, errNoValue := loadBase64ValueAsMap(row) if errNoValue { return } - for k := range dataMap { - if rowMap[k] != nil { - fmt.Printf("\"%v\"%s", rowMap[k], recordSeparator) - } else { - fmt.Printf("\"-\"%s", recordSeparator) - } + for _, k := range keys { + fmt.Printf("\"%v\"%s", rowMap[k], recordSeparator) } fmt.Printf("%s", rowSeparator) } @@ -271,7 +272,7 @@ os.Exit(0) } } -func loadBase64ValueAsMap(metric MetricModel) (map[string]interface{}, bool) { +func loadBase64ValueAsMap(metric MetricModel) (map[string]any, bool) { decodedBytes, err := base64.StdEncoding.DecodeString(metric.Value) if err != nil { fmt.Println("Error decoding string:", err) @@ -279,7 +280,7 @@ return nil, true } decoded := string(decodedBytes) - var dataMap map[string]interface{} + var dataMap map[string]any json.Unmarshal([]byte(decoded), &dataMap) return dataMap, false }