diff

package module
v0.0.0-...-20ebb0f Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2021 License: BSD-3-Clause Imports: 12 Imported by: 25

README

diff GoDoc

Module github.com/pkg/diff can be used to create, modify, and print diffs.

The top level package, diff, contains convenience functions for the most common uses.

The subpackages provide very fine-grained control over every aspect:

  • myers creates diffs using the Myers diff algorithm.
  • edit contains the core diff data types.
  • ctxt provides tools to reduce the amount of context in a diff.
  • write provides routines to write diffs in standard formats.

License: BSD 3-Clause.

Contributing

Contributions are welcome. However, I am not always fast to respond. I apologize for any sadness or frustration that that causes.

Useful background reading about diffs:

This module has not yet reached v1.0; the API is not yet settled (issue #18).

Documentation

Overview

Package diff contains high level routines that generate a textual diff.

It is implemented in terms of the other packages in this module. If you want fine-grained control, want to inspect a diff programmatically, want to provide a context for cancellation, need to diff gigantic files that don't fit in memory, or want to diff unusual things, use the lower level packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Slices

func Slices(aName, bName string, a, b interface{}, w io.Writer, options ...write.Option) error

Slices diffs slices a and b and writes the result to w. It uses fmt.Print to print the elements of a and b. It uses reflect.DeepEqual to compare elements of a and b. It uses aName and bName as the names of a and b in the output.

func Text

func Text(aFile, bFile string, a, b interface{}, w io.Writer, options ...write.Option) error

Text diffs a and b and writes the result to w. It treats a and b as text, and splits their contents into lines using bufio.ScanLines. aFile and bFile are filenames to use in the output.

a and b each may be nil or may have type string, []byte, or io.Reader. If nil, the text is read from the filename.

Types

This section is empty.

Directories

Path Synopsis
cmd
pkg-diff-example
Command pkg-diff-example implements a subset of the diff command using github.com/pkg/diff.
Command pkg-diff-example implements a subset of the diff command using github.com/pkg/diff.
Package ctxt provides routines to reduce the amount of context in an edit script.
Package ctxt provides routines to reduce the amount of context in an edit script.
Package edit provides edit scripts.
Package edit provides edit scripts.
Package intern provides string interning.
Package intern provides string interning.
Package myers implements the Myers diff algorithm.
Package myers implements the Myers diff algorithm.
Package write provides routines for writing diffs.
Package write provides routines for writing diffs.

Jump to

Keyboard shortcuts

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