
output
Index
- func FormatBytes(n int64) string
- func FormatDuration(d time.Duration) string
- func KeyValues(w io.Writer, pairs [][2]string) error
- func PrettyJSON(w io.Writer, raw []byte) error
- func RenderValue(w io.Writer, raw []byte) error
- func Table(w io.Writer, headers []string, rows [][]string) error
- type Format
func FormatBytes
FormatBytes renders a byte count in IEC units (KiB, MiB, GiB, …) with one decimal place. Values under 1024 render as plain bytes, e.g. “512 B”.
func FormatDuration
FormatDuration renders d for operator-facing output. Values under one second show milliseconds (“340ms”), under one minute show seconds with one decimal (“1.2s”), and above show minutes with one decimal (“2.5m”).
func KeyValues
KeyValues writes a left-aligned key/value block to w, padding keys to a common width so the values line up. Used for single-record summaries where a full table would be noise.
func PrettyJSON
PrettyJSON writes raw JSON bytes to w, indented for readability. Bytes that do not parse as JSON are written through unchanged so a non-JSON error body still reaches the operator. Operating on raw bytes (rather than a decoded value) keeps key order and shape identical to what the server emitted.
func RenderValue
RenderValue decodes raw JSON and writes it as an indented, YAML-like text block to w. Non-JSON input is written through unchanged.
func Table
Table writes a column-aligned table to w with a header row, a dashed separator sized to each header, and one line per row. Column widths are computed by text/tabwriter. Rows shorter than the header are padded with blanks so ragged input still aligns.
type Format
Format selects how a command renders its result.
func FromJSON
FromJSON maps the --json boolean flag onto a Format. Absent flag renders human-readable text; present flag renders raw JSON.
func (Format) IsJSON
IsJSON reports whether the format is raw JSON.
Generated by gomarkdoc