diff

package
v0.807.0 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: AGPL-3.0 Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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