difflib

package
v2.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package difflib provides a unified diff for sequences of strings.

It exposes the unified diff formatter used internally by github.com/go-openapi/testify/v2.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetUnifiedDiffString

func GetUnifiedDiffString(diff UnifiedDiff) (string, error)

GetUnifiedDiffString is like WriteUnifiedDiff but returns the diff as a string instead of writing to an io.Writer.

func SplitLines

func SplitLines(s string) []string

SplitLines splits a string on "\n" while preserving them. The output can be used as input for the UnifiedDiff structure.

func WriteUnifiedDiff

func WriteUnifiedDiff(writer io.Writer, diff UnifiedDiff) error

WriteUnifiedDiff writes the comparison between two sequences of lines.

It generates the delta as a unified diff.

Types

type Formatter

type Formatter = idifflib.Formatter

Formatter is a formatting function like fmt.Printf.

type FormatterBuilder

type FormatterBuilder = idifflib.FormatterBuilder

FormatterBuilder is a function that builds a Formatter given a buffered bufio.Writer.

type Options

type Options = idifflib.Options

Options to fine-tune the rendering of the diff output.

type Printer

type Printer idifflib.Printer

Printer outputs a formatted string, e.g. to some underlying writer.

type PrinterBuilder

type PrinterBuilder = idifflib.PrinterBuilder

PrinterBuilder is a function that builds a Printer given a buffered bufio.Writer.

type UnifiedDiff

type UnifiedDiff = idifflib.UnifiedDiff

UnifiedDiff holds the unified diff parameters.

Jump to

Keyboard shortcuts

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