linediff

package
v0.30.0 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2026 License: MIT 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 linediff compares texts line by line (Myers) and renders the difference as a unified diff.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Count

func Count(old, new []byte) (added, removed int)

Count reports how many lines going from old to new adds and removes.

func HunkHeader

func HunkHeader(aStart, aLen, bStart, bLen int) string

HunkHeader is the "@@ … @@" line of a hunk that starts at the 0-based lines aStart / bStart and spans aLen / bLen lines, without the newline.

func Hunks

func Hunks(old, new []byte) string

Hunks renders the hunks of a unified diff from old to new, without the file header; "" when they are equal.

func SplitLines

func SplitLines(b []byte) []string

SplitLines splits after each '\n', keeping the terminator so that a final line without newline differs from the same line with one.

func Unified

func Unified(path string, old, new []byte) string

Unified renders a unified diff from old to new for path. A nil old means the file is created, a nil new that it is deleted. Equal inputs give "".

Types

This section is empty.

Jump to

Keyboard shortcuts

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