diff

package
v0.77.0 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package diff renders a `git diff --no-prefix`-style unified-diff string from two text inputs. The implementation is a line-level Myers algorithm with a hard output cap so a pathological input cannot blow the confirmation prompt to megabytes.

The package has no external dependencies and is safe to call with arbitrary byte sequences (CR, NUL, mixed-encoding bytes are passed through verbatim — line splitting is on `\n` only, the same as `git diff` for a binary-ish file).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Unified

func Unified(name, oldContent, newContent string) string

Unified returns a unified-diff block describing the change from oldContent to newContent for a file conventionally named name.

Identical inputs → empty string.
Empty oldContent → header + every line of newContent prefixed with "+".
Empty newContent → header + every line of oldContent prefixed with "-".

Output is capped at the package-level maxLines / maxBytes; when the cap fires, a single "[... N lines truncated ...]" marker is emitted at the truncation point and the rest of the diff is dropped.

Types

This section is empty.

Jump to

Keyboard shortcuts

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