diff

package
v0.0.0-...-f39ad0c Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2023 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Overview

Package diff implements the Myers diff algorithm.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyEdits

func ApplyEdits(a []string, operations []*Op) []string

func SplitLines

func SplitLines(text string) []string

Types

type Hunk

type Hunk struct {
	FromLine int
	ToLine   int
	Lines    []Line
}

type Line

type Line struct {
	Kind    OpKind
	Content string
}

type Op

type Op struct {
	Kind    OpKind
	Content []string // content from b
	I1, I2  int      // indices of the line in a
	J1      int      // indices of the line in b, J2 implied by len(Content)
}

func Operations

func Operations(a, b []string) []*Op

Operations returns the list of operations to convert a into b, consolidating operations for multiple lines and not including equal lines.

type OpKind

type OpKind int
const (
	Delete OpKind = iota
	Insert
	Equal
)

func (OpKind) String

func (k OpKind) String() string

type Unified

type Unified struct {
	From, To string
	Hunks    []*Hunk
}

func ToUnified

func ToUnified(from, to string, lines []string, ops []*Op) Unified

func (Unified) Format

func (u Unified) Format(f fmt.State, r rune)

Jump to

Keyboard shortcuts

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