printError writes a JSON error object to stderr and returns err unchanged so callers can `return printError(err)`.
(err error)
| 267 | // printError writes a JSON error object to stderr and returns err unchanged so |
| 268 | // callers can `return printError(err)`. |
| 269 | func printError(err error) error { |
| 270 | data, _ := json.Marshal(map[string]string{"error": err.Error()}) |
| 271 | fmt.Fprintln(os.Stderr, string(data)) |
| 272 | |
| 273 | return err |
| 274 | } |
| 275 | |
| 276 | // printTable writes aligned tabular output to stdout. |
| 277 | func printTable(headers []string, rows [][]string) { |