render

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package render turns slices of record structs into one of the output formats weibo-cli supports: table, json, jsonl, csv, tsv, url, and raw. It works off struct reflection and json tags, so any record type renders without per-type code.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Format

type Format string

Format is an output rendering format.

const (
	FormatTable Format = "table"
	FormatJSON  Format = "json"
	FormatJSONL Format = "jsonl"
	FormatCSV   Format = "csv"
	FormatTSV   Format = "tsv"
	FormatURL   Format = "url"
	FormatRaw   Format = "raw"
)

func (Format) Valid

func (f Format) Valid() bool

Valid reports whether f is one of the supported formats.

type Renderer

type Renderer struct {
	Format   Format
	Fields   []string
	NoHeader bool
	Template string
	// contains filtered or unexported fields
}

Renderer writes records in a chosen format.

func New

func New(w io.Writer, format Format, fields []string, noHeader bool, tmpl string) *Renderer

New builds a Renderer writing to w.

func (*Renderer) Render

func (r *Renderer) Render(records any) error

Render writes records (a slice of structs, or a single struct) in the configured format.

Jump to

Keyboard shortcuts

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