writeJSON pretty-prints v as 2-space indented JSON with a trailing newline.
(out io.Writer, v any)
| 622 | |
| 623 | // writeJSON pretty-prints v as 2-space indented JSON with a trailing newline. |
| 624 | func writeJSON(out io.Writer, v any) error { |
| 625 | data, err := json.MarshalIndent(v, "", " ") |
| 626 | if err != nil { |
| 627 | return err |
| 628 | } |
| 629 | data = append(data, '\n') |
| 630 | _, err = out.Write(data) |
| 631 | return err |
| 632 | } |
| 633 | |
| 634 | // inIsTTY reports whether the supplied reader is a *os.File backed by a |
| 635 | // terminal. Tests using bytes.Buffer return false, which is what we want |
no test coverage detected