printJSON marshals v as indented JSON and writes it to stdout.
(v any)
| 254 | |
| 255 | // printJSON marshals v as indented JSON and writes it to stdout. |
| 256 | func printJSON(v any) error { |
| 257 | data, err := json.MarshalIndent(v, "", " ") |
| 258 | if err != nil { |
| 259 | return fmt.Errorf("json marshal: %w", err) |
| 260 | } |
| 261 | |
| 262 | fmt.Println(string(data)) |
| 263 | |
| 264 | return nil |
| 265 | } |
| 266 | |
| 267 | // printError writes a JSON error object to stderr and returns err unchanged so |
| 268 | // callers can `return printError(err)`. |
no outgoing calls