write

package
v0.0.0-...-20ebb0f Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2021 License: BSD-3-Clause Imports: 4 Imported by: 18

Documentation

Overview

Package write provides routines for writing diffs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Unified

func Unified(e edit.Script, w io.Writer, ab Pair, opts ...Option) error

Unified writes e to w using unified diff format. ab writes the individual elements. Opts are optional write arguments. Unified returns the number of bytes written and the first error (if any) encountered. Before writing, edit scripts usually have their context reduced, such as by a call to ctxt.Size.

Types

type Option

type Option interface {
	// contains filtered or unexported methods
}

An Option modifies behavior when writing a diff.

func Names

func Names(a, b string) Option

Names provides the before/after names for writing a diff. They are traditionally filenames.

func TerminalColor

func TerminalColor() Option

TerminalColor specifies that a diff intended for a terminal should be written using colors.

Do not use TerminalColor if TERM=dumb is set in the environment.

type Pair

type Pair interface {
	// WriteATo writes the element a[aᵢ] to w.
	WriteATo(w io.Writer, ai int) (int, error)
	// WriteBTo writes the element b[bᵢ] to w.
	WriteBTo(w io.Writer, bi int) (int, error)
}

A Pair supports writing a unified diff, element by element. A is the initial state; B is the final state.

Jump to

Keyboard shortcuts

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