Documentation
¶
Index ¶
- Constants
- func ArrayToText(value []interface{}) (string, error)
- func BoolToPostgresText(value bool) string
- func BoolToStandardText(value bool) string
- func ConvertValueToText(value interface{}) (string, error)
- func DisplayNameToUUIDv7(name string) (uuid.UUID, error)
- func ExtractUUIDv7Time(id [16]byte) time.Time
- func IsDisplayName(s string) bool
- func IsUUIDv7(id [16]byte) bool
- func JSONBToText(value interface{}) (string, error)
- func NormalizeForJSON(value interface{}) interface{}
- func ParseCSV(line string) ([]string, []interface{}, error)
- func ParseCSVBulk(data []byte) ([]string, [][]interface{}, error)
- func ParseCSVBulkNoHeaders(data []byte, columns []string) ([]string, [][]interface{}, error)
- func ParseCSVWithHeader(data string) ([]string, []interface{}, error)
- func ParseJSON(jsonStr string) ([]string, []interface{}, error)
- func ParseJSONBulk(data []byte) ([]string, [][]interface{}, error)
- func ParseTSV(line string) ([]string, []interface{}, error)
- func ParseTSVBulk(data []byte) ([]string, [][]interface{}, error)
- func ParseTSVBulkNoHeaders(data []byte, columns []string) ([]string, [][]interface{}, error)
- func ParseTSVWithHeader(data string) ([]string, []interface{}, error)
- func ParseYAML(yamlStr string) ([]string, []interface{}, error)
- func ParseYAMLBulk(data []byte) ([]string, [][]interface{}, error)
- func RowToCSV(columns []string, values []interface{}) ([]byte, error)
- func RowToJSON(columns []string, values []interface{}) ([]byte, error)
- func RowToTSV(columns []string, values []interface{}) ([]byte, error)
- func RowToYAML(columns []string, values []interface{}) ([]byte, error)
- func RowsToCSV(columns []string, rows [][]interface{}) ([]byte, error)
- func RowsToCSVWithHeaders(columns []string, rows [][]interface{}) ([]byte, error)
- func RowsToJSON(columns []string, rows [][]interface{}) ([]byte, error)
- func RowsToTSV(columns []string, rows [][]interface{}) ([]byte, error)
- func RowsToTSVWithHeaders(columns []string, rows [][]interface{}) ([]byte, error)
- func RowsToYAML(columns []string, rows [][]interface{}) ([]byte, error)
- func TimeToText(t time.Time) string
- func UUIDv7ToDisplayName(id [16]byte) string
- func ValueToString(value interface{}) string
Constants ¶
const DisplayNameLayout = "2006-01-02T150405.000Z"
DisplayNameLayout is the time format for the timestamp portion of UUIDv7 display names. Uses millisecond precision, UTC, filesystem-safe (no colons).
Variables ¶
This section is empty.
Functions ¶
func ArrayToText ¶
ArrayToText converts a PostgreSQL array to JSON array text
func BoolToPostgresText ¶
BoolToPostgresText converts a boolean to PostgreSQL text format (t/f)
func BoolToStandardText ¶
BoolToStandardText converts a boolean to standard text format (true/false)
func ConvertValueToText ¶
ConvertValueToText converts a PostgreSQL value to its text representation Handles special PostgreSQL types like JSONB, arrays, and complex types
func DisplayNameToUUIDv7 ¶ added in v0.7.0
DisplayNameToUUIDv7 parses a display name back to a UUIDv7. This is the inverse of UUIDv7ToDisplayName -- fully reversible with no lookup needed.
func ExtractUUIDv7Time ¶ added in v0.7.0
ExtractUUIDv7Time extracts the millisecond timestamp from a UUIDv7. UUIDv7 stores a Unix timestamp in milliseconds in the first 48 bits.
func IsDisplayName ¶ added in v0.7.0
IsDisplayName checks whether a string looks like a UUIDv7 display name (timestamp-base36 format). Used for path resolution to distinguish display names from hex UUIDs.
func IsUUIDv7 ¶ added in v0.7.0
IsUUIDv7 checks whether a UUID is version 7 by inspecting the version bits at positions 48-51 (the high nibble of byte 6).
func JSONBToText ¶
JSONBToText converts a JSONB value to compact JSON text
func NormalizeForJSON ¶
func NormalizeForJSON(value interface{}) interface{}
NormalizeForJSON converts PostgreSQL-specific types to JSON-compatible types. Unlike ConvertValueToText, this preserves JSON-native types (strings, numbers, bools, nil) while converting problematic types like [16]byte UUIDs to strings.
func ParseCSV ¶
ParseCSV parses a CSV line into columns and values Format: value1,value2,"quoted value, with comma" Empty values are treated as NULL Note: This requires column names to be known externally (schema order) Used for bare row writes without explicit format extension.
func ParseCSVBulk ¶
ParseCSVBulk parses CSV data with a header row into columns and rows. First line must be column names, subsequent lines are data rows. Empty fields are treated as NULL.
func ParseCSVBulkNoHeaders ¶
ParseCSVBulkNoHeaders parses CSV data without a header row. All rows are data rows, columns are provided by caller. Empty fields are treated as NULL.
func ParseCSVWithHeader ¶
ParseCSVWithHeader parses CSV data with a header row (two lines). First line is column names, second line is values. Returns columns from header and corresponding values. Empty values are treated as NULL. Used for .csv format writes which support PATCH semantics.
func ParseJSON ¶
ParseJSON parses a JSON object into columns and values Format: {"col1": "value1", "col2": 42, "col3": null}
func ParseJSONBulk ¶
ParseJSONBulk parses a JSON array of objects into columns and rows. All objects must have the same keys (column names). Null values are preserved.
func ParseTSV ¶
ParseTSV parses a TSV line into columns and values Format: value1\tvalue2\tvalue3 Empty values are treated as NULL Note: This requires column names to be known externally (schema order) Used for bare row writes without explicit format extension.
func ParseTSVBulk ¶
ParseTSVBulk parses TSV data with a header row into columns and rows. First line must be column names, subsequent lines are data rows. Empty fields are treated as NULL.
func ParseTSVBulkNoHeaders ¶
ParseTSVBulkNoHeaders parses TSV data without a header row. All rows are data rows, columns are provided by caller. Empty fields are treated as NULL.
func ParseTSVWithHeader ¶
ParseTSVWithHeader parses TSV data with a header row (two lines). First line is column names, second line is values. Returns columns from header and corresponding values. Empty values are treated as NULL. Used for .tsv format writes which support PATCH semantics.
func ParseYAML ¶
ParseYAML parses a YAML document into columns and values Format:
col1: value1 col2: 42 col3: null
func ParseYAMLBulk ¶
ParseYAMLBulk parses multi-document YAML into columns and rows. Each document (separated by ---) represents one row. All documents must have the same keys (column names).
func RowToCSV ¶
RowToCSV converts a database row to CSV format (RFC 4180) Columns are in schema order, comma-separated, no header row NULL values are represented as empty fields Fields containing commas, quotes, or newlines are quoted
func RowToJSON ¶
RowToJSON converts a database row to compact JSON format. Returns a single-line JSON object with column names as keys. NULL values are represented as JSON null. Characters like &, <, > are NOT escaped (no HTML safety escaping).
func RowToTSV ¶
RowToTSV converts a database row to TSV format Columns are in schema order, tab-separated, no header row NULL values are represented as empty fields
func RowToYAML ¶
RowToYAML converts a database row to YAML format. Column names are used as keys, producing self-documenting output. NULL values are represented as YAML null. Output includes leading document separator (---) for proper multi-document concatenation. Unicode characters (including emoji) are preserved as-is, not escaped.
Example output:
--- id: 1 name: Alice email: alice@example.com created_at: null
func RowsToCSV ¶
RowsToCSV converts multiple database rows to CSV format (RFC 4180). Data rows only, no header row (consistent with row-as-file reads). Column names available via .info/columns if needed. NULL values are represented as empty fields. Fields containing commas, quotes, or newlines are quoted. Empty input returns empty output.
Parameters:
- columns: Column names in database order (used for validation only)
- rows: Row values as [][]interface{}
Returns CSV data with trailing newline per row.
func RowsToCSVWithHeaders ¶
RowsToCSVWithHeaders converts multiple database rows to CSV format with a header row. First row is column names, subsequent rows are data. Used for round-trip compatibility with import.
func RowsToJSON ¶
RowsToJSON converts multiple database rows to JSON array format. Returns a JSON array of objects, with column names as keys. NULL values are represented as JSON null. Empty input returns "[]" (empty array). Characters like &, <, > are NOT escaped (no HTML safety escaping).
Parameters:
- columns: Column names in database order
- rows: Row values as [][]interface{}
Returns JSON array with pretty printing for readability.
func RowsToTSV ¶
RowsToTSV converts multiple database rows to TSV format. Data rows only, no header row (consistent with row-as-file reads). Column names available via .info/columns if needed. NULL values are represented as empty fields. Tab-separated, no quoting. Empty input returns empty output.
Parameters:
- columns: Column names in database order (used for validation only)
- rows: Row values as [][]interface{}
Returns TSV data with trailing newline per row.
func RowsToTSVWithHeaders ¶
RowsToTSVWithHeaders converts multiple database rows to TSV format with a header row. First row is column names, subsequent rows are data. Used for round-trip compatibility with import.
func RowsToYAML ¶
RowsToYAML converts multiple database rows to multi-document YAML format. Each row becomes a separate YAML document with "---" separator. Column names are used as keys, producing self-documenting output. NULL values are represented as YAML null. Empty input returns empty string.
Parameters:
- columns: Column names in database order
- rows: Row values as [][]interface{}
Returns multi-document YAML with "---" separators.
func TimeToText ¶
TimeToText converts a time.Time to RFC3339Nano format (full precision)
func UUIDv7ToDisplayName ¶ added in v0.7.0
UUIDv7ToDisplayName converts a UUIDv7 to a human-readable display name: "<timestamp>-<base36 entropy>", e.g. "2026-04-07T143000.123Z-zzz0063hd8e5r42".
The format is fully reversible via DisplayNameToUUIDv7. It encodes all 122 meaningful bits of the UUID (48 timestamp + 12 rand_a + 62 rand_b). The 4 version bits and 2 variant bits are fixed constants reconstructed on decode.
Base36 (0-9a-z) is used for the entropy portion to be case-insensitive safe on macOS APFS.
func ValueToString ¶
func ValueToString(value interface{}) string
ValueToString converts a database value to its string representation NULL values become empty strings This is a public function used by TSV, CSV, and column file formatting
Delegates to ConvertValueToText for consistent type handling across all formats, including proper serialization of PostgreSQL types like numeric, UUID, etc.
Types ¶
This section is empty.