Documentation
¶
Overview ¶
Package render formats query results for terminal output. Phase 0 provides a minimal aligned text table; json/csv and pipe-aware output land in Phase 1 (see docs/TASKS.md C1/C2).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Cell ¶ added in v0.12.0
Cell formats a single value for human-facing display: NULL for nil, and a hex literal (0x…) for binary values. Drivers normalize []byte to string, so binary columns (e.g. MySQL binary(16) UUIDs) arrive as invalid-UTF-8 strings that would otherwise print as mojibake. Machine formats (csv/tsv/json) do not use this — they keep the raw data.
Types ¶
type Format ¶
type Format string
Format is an output format for a result set.
const ( // FormatTable is a human-readable aligned text table (TTY default). FormatTable Format = "table" // FormatJSON is a JSON array of objects, one per row, preserving column order. FormatJSON Format = "json" // FormatCSV is comma-separated values with a header row. FormatCSV Format = "csv" // FormatTSV is tab-separated values with a header row (pipe default). FormatTSV Format = "tsv" )
func ParseFormat ¶
ParseFormat validates and returns a Format.
type Options ¶
type Options struct {
Format Format
// MaxCellWidth truncates table cells longer than this many runes (0 =
// unlimited). Ignored by machine formats (csv/tsv/json).
MaxCellWidth int
}
Options configures rendering.
type Source ¶
type Source interface {
Columns() []string
// Next returns the next row; ok is false at end-of-rows (then err carries
// any iteration error).
Next() (row []any, ok bool, err error)
}
Source is a pull-based result set for streaming rendering, so large results (csv/tsv/json) are written row-by-row without buffering the whole set in memory. driver.Rows is adapted to this in the cmd layer.