EncodeJSON is a helper function to decorate any error message with a bit more context and avoid writing the same code over and over for printers.
(out io.Writer, obj any)
| 104 | // EncodeJSON is a helper function to decorate any error message with a bit more |
| 105 | // context and avoid writing the same code over and over for printers. |
| 106 | func EncodeJSON(out io.Writer, obj any) error { |
| 107 | enc := json.NewEncoder(out) |
| 108 | err := enc.Encode(obj) |
| 109 | if err != nil { |
| 110 | return fmt.Errorf("unable to write JSON output: %w", err) |
| 111 | } |
| 112 | return nil |
| 113 | } |
| 114 | |
| 115 | // EncodeYAML is a helper function to decorate any error message with a bit more |
| 116 | // context and avoid writing the same code over and over for printers |
no test coverage detected
searching dependent graphs…