modulepackage
0.0.0-20230423230343-2ebdcebdccc1
Repository: https://github.com/akedrou/textdiff.git
Documentation: pkg.go.dev
# README
Text/diff
This is a copy of the Go text diffing package that gopls uses to generate unified diffs. There is some discussion about moving the package out of an internal package, but in the meantime this can be used.
This is identical to https://github.com/hexops/gotextdiff, but that hasn't been updated with the newer API, so I just did the same thing.
The code is entirely written by the Go Authors.
No PRs will be accepted here - please contribute to the upstream source!
License
# Packages
Package difftest supplies a set of tests that will operate on any implementation of a diff algorithm as exposed by "golang.org/x/tools/internal/diff".
package lcs contains code to find longest-common-subsequences (and diffs).
Package myers implements the Myers diff algorithm.
Package testenv contains helper functions for skipping tests based on which tools are present in the environment.
# Functions
Apply applies a sequence of edits to the src buffer and returns the result.
ApplyBytes is like Apply, but it accepts a byte slice.
Bytes computes the differences between two byte slices.
SortEdits orders a slice of Edits by (start, end) offset.
Strings computes the differences between two strings.
ToUnified applies the edits to content and returns a unified diff.
Unified returns a unified diff of the old and new strings.
# Constants
Delete is the operation kind for a line that is present in the input but not in the output.
Equal is the operation kind for a line that is the same in the input and output, often used to provide context around edited lines.
Insert is the operation kind for a line that is new in the output.
# Type aliases
OpKind is used to denote the type of operation a line represents.