Documentation
¶
Overview ¶
Package table provides common interfaces, row adapters, and errors for the format-specific table packages in this module.
Rendering is implemented by the text, html, markdown, backlog, and csv subpackages. Applications choose one of those packages according to the output format they need. This package does not select a format or write output itself.
Each format package provides a Table for batch input and a Stream for incremental input. A Table implements Tabular, whose Render method accepts all body rows at once as [][]any. A Stream implements Streamer, whose Render method accepts one []any body row at a time and whose Close method must be called after the final row.
TableOf converts a typed slice to [][]any. StreamOf adapts an iterator to rows without first collecting the sequence in memory.
Body values are converted consistently across format packages. Scalars, errors, fmt.Stringer values, and byte slices use their text form. Error takes precedence when a value also implements fmt.Stringer. Other values use the representation produced by fmt.Sprint. Nil values and empty strings, slices, and arrays use the configured placeholder. Transformer options can replace the default display text without evaluating that representation.
Failures from format packages are returned as Error values that identify the package and unwrap the underlying cause. The sentinel errors in this package describe shared conditions and can be matched with errors.Is.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrWriteFailed reports an error returned by the output writer. // Callers can match it with errors.Is. ErrWriteFailed = errors.New("write failed") // ErrClosed reports a Render call after Close on a stream. // Callers can match it with errors.Is. ErrClosed = errors.New("render after close") // ErrColumnCount reports a body or footer row containing more cells than // the established column count. Callers can match it with errors.Is. ErrColumnCount = errors.New("column count exceeded") // ErrHeaderRequired reports a missing header for a format that requires // one. Callers can match it with errors.Is. ErrHeaderRequired = errors.New("header is required") // ErrDelimiter reports an unsupported field delimiter. // Callers can match it with errors.Is. ErrDelimiter = errors.New("invalid delimiter") )
Functions ¶
Types ¶
type Error ¶
type Error struct {
Pkg string // Package name, such as "text".
Err error // The underlying error.
}
Error is the outermost wrapper returned by a format package. It identifies the package associated with an underlying error.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package backlog renders tabular data using [Backlog table notation] and writes the result to an io.Writer.
|
Package backlog renders tabular data using [Backlog table notation] and writes the result to an io.Writer. |
|
Package csv renders tabular data as delimiter-separated records written to an io.Writer.
|
Package csv renders tabular data as delimiter-separated records written to an io.Writer. |
|
Package examples provides representative data sets for the example commands and benchmarks in this module.
|
Package examples provides representative data sets for the example commands and benchmarks in this module. |
|
cmd/generate
command
|
|
|
cmd/print
command
Command print writes selected table examples.
|
Command print writes selected table examples. |
|
Package html formats tabular data as semantic HTML table markup and writes it to an io.Writer.
|
Package html formats tabular data as semantic HTML table markup and writes it to an io.Writer. |
|
internal
|
|
|
align
Package align defines horizontal alignment values shared by format packages.
|
Package align defines horizontal alignment values shared by format packages. |
|
caption
Package caption defines caption positions shared by format packages.
|
Package caption defines caption positions shared by format packages. |
|
catalog
Package catalog generates the examples catalog from its implementation.
|
Package catalog generates the examples catalog from its implementation. |
|
color
Package color defines the wrapper used by format packages to attach format-specific color markup to cell values.
|
Package color defines the wrapper used by format packages to attach format-specific color markup to cell values. |
|
column
Package column provides shared operations for resolving logical columns.
|
Package column provides shared operations for resolving logical columns. |
|
decorate
Package decorate defines the wrapper used by format packages to attach format-specific decoration markup to cell values.
|
Package decorate defines the wrapper used by format packages to attach format-specific decoration markup to cell values. |
|
display
Package display measures terminal display width and scans strings by display units.
|
Package display measures terminal display width and scans strings by display units. |
|
param
Package param defines format-independent constants shared by format packages.
|
Package param defines format-independent constants shared by format packages. |
|
repeat
Package repeat appends repeated bytes to caller-owned buffers.
|
Package repeat appends repeated bytes to caller-owned buffers. |
|
scope
Package scope identifies the header, body, and footer of a table and stores values or column masks selected independently for those parts.
|
Package scope identifies the header, body, and footer of a table and stores values or column masks selected independently for those parts. |
|
skills
Package skills implements maintenance commands invoked by repository skills.
|
Package skills implements maintenance commands invoked by repository skills. |
|
span
Package span detects consecutive equal display values for vertical and horizontal cell spanning.
|
Package span detects consecutive equal display values for vertical and horizontal cell spanning. |
|
testutil
Package testutil provides assertions, fixtures, and mocks shared by the module's tests.
|
Package testutil provides assertions, fixtures, and mocks shared by the module's tests. |
|
value
Package value converts arbitrary Go values to display text held in caller-owned storage.
|
Package value converts arbitrary Go values to display text held in caller-owned storage. |
|
version
Package version holds the module version maintained by release tooling.
|
Package version holds the module version maintained by release tooling. |
|
Package markdown renders tabular data as GitHub Flavored Markdown tables written to an io.Writer.
|
Package markdown renders tabular data as GitHub Flavored Markdown tables written to an io.Writer. |
|
Package text formats tabular data as bordered text tables and writes them to an io.Writer.
|
Package text formats tabular data as bordered text tables and writes them to an io.Writer. |








