package edit
import "github.com/pkg/diff/edit"
Package edit provides edit scripts. Edit scripts are a core notion for diffs. They represent a way to go from A to B by a sequence of insertions, deletions, and equal elements.
Index ¶
- type Op
- type Range
- func (r *Range) IsDelete() bool
- func (r *Range) IsEqual() bool
- func (r *Range) IsInsert() bool
- func (r *Range) Len() int
- func (r *Range) Op() Op
- type Script
Types ¶
type Op ¶
type Op int8
An Op is a edit operation in a Script.
func (Op) String ¶
type Range ¶
A Range is a pair of clopen index ranges. It represents the elements A[LowA:HighA] and B[LowB:HighB].
func (*Range) IsDelete ¶
IsDelete reports whether r represents a deletion in a Script. If so, the deleted elements are A[LowA:HighA].
func (*Range) IsEqual ¶
IsEqual reports whether r represents a series of equal elements in a Script. If so, the elements A[LowA:HighA] are equal to the elements B[LowB:HighB].
func (*Range) IsInsert ¶
IsInsert reports whether r represents an insertion in a Script. If so, the inserted elements are B[LowB:HighB].
func (*Range) Len ¶
Len reports the number of elements in r. In a deletion, it is the number of deleted elements. In an insertion, it is the number of inserted elements. For equal elements, it is the number of equal elements.
func (*Range) Op ¶
Op reports what kind of operation r represents. This can also be determined by calling r.IsInsert, r.IsDelete, and r.IsEqual, but this form is sometimes more convenient to use.
type Script ¶
type Script struct { Ranges []Range }
A Script is an edit script to alter A into B.
func NewScript ¶
NewScript returns a Script containing the ranges r. It is only a convenience wrapper used to reduce line noise.
func (*Script) IsIdentity ¶
IsIdentity reports whether s is the identity edit script, that is, whether A and B are identical.
func (*Script) Stat ¶
Stat reports the total number of insertions and deletions in s.
Source Files ¶
- Version
- v0.0.0-20241224192749-4e6772a4315c (latest)
- Published
- Dec 24, 2024
- Platform
- linux/amd64
- Imports
- 3 packages
- Last checked
- 1 hour ago –
Tools for package owners.