fortify: serialise ps with string as key
All checks were successful
Tests / Go tests (push) Successful in 40s
Nix / NixOS tests (push) Successful in 2m59s

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
Ophestra 2024-12-21 23:52:48 +09:00
parent bf11241649
commit f2869c4235
Signed by: cat
SSH Key Fingerprint: SHA256:gQ67O0enBZ7UdZypgtspB2FDM1g3GVw8nX0XSdcFw8Q

View File

@ -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")
}
}