output

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package output 实现查询结果的多种格式化输出。

支持格式:table(默认对齐表格)、json、csv、yaml、vertical(\G 风格,每行一记录)。 输入统一为 driver.Result,与具体数据库解耦。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Write

func Write(w io.Writer, r *driver.Result, opt Options) error

Write 把结果按指定格式写到 w。

Types

type Format

type Format string

Format 是输出格式枚举。

const (
	FormatTable    Format = "table"
	FormatJSON     Format = "json"
	FormatCSV      Format = "csv"
	FormatYAML     Format = "yaml"
	FormatVertical Format = "vertical"
)

func ParseFormat

func ParseFormat(s string) Format

ParseFormat 把字符串转为 Format,非法值回退到 table。

type Options

type Options struct {
	Format   Format
	NoHeader bool // table/csv 时是否省略表头
}

Options 控制输出行为。

Jump to

Keyboard shortcuts

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