Help us shape the future of Go! Take the 2026 Go Developer Survey

readable

package
v1.29.1 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package readable renders API values as plain, labeled text.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Text

func Text(text string) string

Text escapes terminal controls and directional marks while preserving ordinary newlines and tabs. It adds no newline and does not redact sensitive content.

func Write

func Write(w io.Writer, value gjson.Result) error

Write renders value in its original field order, without a pager or a table. Strings and array values are complete, including multiline text. Terminal controls are escaped even when w is a redirected output stream.

func WriteText

func WriteText(out io.Writer, value string) error

WriteText escapes terminal controls and writes one complete text result. It appends a newline only when the text does not already end with one.

Types

type StreamEvent added in v1.22.0

type StreamEvent struct {
	Parts   []StreamPart
	Details gjson.Result
}

StreamEvent carries projected text and any accompanying structured details. An empty event represents progress without visible content.

type StreamPart added in v1.22.0

type StreamPart struct {
	Key, Text, Label string
	Snapshot         bool
}

StreamPart describes one identified text component. A snapshot contains its complete text so far; other parts append a delta. Labels distinguish alternatives.

type StreamWriter added in v1.22.0

type StreamWriter struct {
	// contains filtered or unexported fields
}

StreamWriter emits text immediately and retains only a digest per component. It never consumes an iterator or chooses which API fields to display.

func NewStreamWriter added in v1.22.0

func NewStreamWriter(out io.Writer) *StreamWriter

func (*StreamWriter) Finish added in v1.22.0

func (w *StreamWriter) Finish() error

Finish closes partial text before the caller reports completion or an error.

func (*StreamWriter) HasOutput added in v1.22.0

func (w *StreamWriter) HasOutput() bool

func (*StreamWriter) Write added in v1.22.0

func (w *StreamWriter) Write(event StreamEvent) error

func (*StreamWriter) WriteValue added in v1.22.0

func (w *StreamWriter) WriteValue(value gjson.Result) error

WriteValue preserves unfamiliar or non-text content as ordinary labeled data.

Jump to

Keyboard shortcuts

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