File: diff.go

package info (click to toggle)
golang-github-poy-onpar 0.3.3-1.1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 456 kB
  • sloc: makefile: 3
file content (31 lines) | stat: -rw-r--r-- 869 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package str

type Type int

const (
	TypeMatch = iota
	TypeReplace
)

// DiffSection represents a single chunk of a diff.
type DiffSection struct {
	Type             Type
	Actual, Expected []rune
}

// Diff represents a full diff of two values.
type Diff interface {
	// Cost is the calculated cost of changing from one value to another.
	// Basically, if provided with multiple diffs, the Differ will always prefer
	// the lowest cost.
	//
	// Generally, a cost of 0 should represent exactly equal values, so negative
	// numbers shouldn't usually be used. However, if they are used, they will
	// work the same as positive values, being preferred over any value higher
	// than them.
	Cost() float64

	// Sections returns all of the sections of the diff. This will be used to
	// generate output, depending on the diff formats being used.
	Sections() []DiffSection
}