From f2869c423547a1f5b8b78428e79d024223c2c09c Mon Sep 17 00:00:00 2001 From: Ophestra Date: Sat, 21 Dec 2024 23:52:48 +0900 Subject: [PATCH] fortify: serialise ps with string as key Signed-off-by: Ophestra --- print.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/print.go b/print.go index f2b60aa..a78f4be 100644 --- a/print.go +++ b/print.go @@ -175,7 +175,11 @@ func printPs(short bool) { } if flagJSON { - printJSON(entries) + es := make(map[string]*state.State, len(entries)) + for id, instance := range entries { + es[id.String()] = instance + } + printJSON(es) return } @@ -215,7 +219,7 @@ func printJSON(v any) { encoder := json.NewEncoder(direct.Stdout) encoder.SetIndent("", " ") if err := encoder.Encode(v); err != nil { - fmsg.Fatalf("cannot serialise as JSON: %v", err) + fmsg.Fatalf("cannot serialise: %v", err) panic("unreachable") } }