diff

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: May 13, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package diff produces unified diff output from two byte slices using the Myers diff algorithm.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Unified

func Unified(a, b []byte, opts Options) string

Unified returns a unified diff string between a and b. Returns "" if a and b are identical. For binary inputs, returns a message matching Fossil's behavior.

Types

type DiffStat

type DiffStat struct {
	Insertions int  // lines present only in b
	Deletions  int  // lines present only in a
	Binary     bool // true if either input contains null bytes
}

DiffStat summarizes the magnitude of changes.

func Stat

func Stat(a, b []byte) DiffStat

Stat returns insertion/deletion counts between a and b.

type Options

type Options struct {
	ContextLines int    // lines of context around changes; 0 means no context
	SrcName      string // source file label for header (e.g. "a/file.txt")
	DstName      string // destination file label for header
}

Options configures diff output.

Jump to

Keyboard shortcuts

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