format

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Write

func Write(w io.Writer, format OutputFormat, headers []string, rows [][]string, jsonVal interface{}) error

Write writes tabular data using the specified output format.

func WriteCSV

func WriteCSV(w io.Writer, headers []string, rows [][]string) error

WriteCSV writes rows with headers as comma-separated values.

func WriteJSON

func WriteJSON(w io.Writer, v interface{}) error

WriteJSON writes the given value as a JSON array to w.

func WriteTSV

func WriteTSV(w io.Writer, headers []string, rows [][]string) error

WriteTSV writes rows with headers as tab-separated values.

func WriteTable

func WriteTable(w io.Writer, headers []string, rows [][]string) error

WriteTable writes rows with headers as an ASCII table.

Types

type OutputFormat

type OutputFormat string

OutputFormat specifies the desired output format.

const (
	FormatTable OutputFormat = "table"
	FormatJSON  OutputFormat = "json"
	FormatCSV   OutputFormat = "csv"
	FormatTSV   OutputFormat = "tsv"
)

func ParseFormat

func ParseFormat(s string) (OutputFormat, error)

ParseFormat parses the output format string.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL