Documentation
¶
Overview ¶
https://github.com/coder/coder/blob/main/LICENSE Extracted and modified from github.com/coder/coder
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DisplayTable ¶
DisplayTable renders a table as a string. The input argument can be:
- a struct slice.
- an interface slice, where the first element is a struct, and all other elements are of the same type, or a TableSeparator.
At least one field in the struct must have a `table:""` tag containing the name of the column in the outputted table.
If `sort` is not specified, the field with the `table:"$NAME,default_sort"` tag will be used to sort. An error will be returned if no field has this tag.
Nested structs are processed if the field has the `table:"$NAME,recursive"` tag and their fields will be named as `$PARENT_NAME $NAME`. If the tag is malformed or a field is marked as recursive but does not contain a struct or a pointer to a struct, this function will return an error (even with an empty input slice).
If sort is empty, the input order will be used. If filterColumns is empty or nil, all available columns are included.
Types ¶
type TableSeparator ¶
type TableSeparator struct{}
This type can be supplied as part of a slice to DisplayTable or to a `TableFormat` `Format` call to render a separator. Leading separators are not supported and trailing separators are ignored by the table formatter. e.g. `[]any{someRow, TableSeparator, someRow}`