render

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package render turns a diff.Result into something a person or a script can read: colored terminal output, a side-by-side table, JSON, or a CSV of just the rows that changed.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CSV

func CSV(w io.Writer, r *diff.Result, o Options) error

CSV writes only the rows that changed, tagged with what happened to them. A modified row appears twice, once with its old values and once with its new ones, so nothing is lost on export.

func ColorEnabled

func ColorEnabled(mode string) bool

ColorEnabled decides whether to emit ANSI codes, honouring NO_COLOR and FORCE_COLOR before falling back to whether stdout is a terminal.

func JSON

func JSON(w io.Writer, r *diff.Result, o Options) error

JSON writes the whole result as one object. Every list is present even when empty, so consumers never have to guard against null.

func SideBySide

func SideBySide(w io.Writer, r *diff.Result, o Options) error

SideBySide lays every change out as a three-column table: the column name, its value in the old file, and its value in the new one.

func TerminalWidth

func TerminalWidth() int

TerminalWidth reports a usable output width, preferring the real terminal size and falling back to COLUMNS and then to a sane default.

func Text

func Text(w io.Writer, r *diff.Result, o Options) error

Text writes the default grouped view: one section per kind of change, with modified rows broken down column by column.

Types

type Options

type Options struct {
	Color         bool
	Width         int
	Limit         int // cap on rows printed per section; 0 means no cap
	ShowReordered bool
	SummaryOnly   bool
}

Options controls presentation, not comparison.

Jump to

Keyboard shortcuts

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