diff3

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2024 License: MIT Imports: 3 Imported by: 1

README

Diff3

A diff3 text merge implementation in Go based on the awesome paper below.

"A Formal Investigation of Diff3" by Sanjeev Khanna, Keshav Kunal, and Benjamin C. Pierce

Usage

import "github.com/nasdf/diff3"
textO := "original"
textA := "changesA"
textB := "changesB"
merge := diff3.Merge(textO, textA, textB)
Customize seperators
diff3.Sep1 = "$$$$$$$"
diff3.Sep2 = "@@@@@@@"
diff3.Sep3 = "*******"
Customize DiffMatchPatch settings
diff3.DiffMatchPatch.DiffTimeout = time.Second
diff3.DiffMatchPatch.DiffEditCost = 4
diff3.DiffMatchPatch.MatchThreshold = 0.5
diff3.DiffMatchPatch.MatchDistance = 1000
diff3.DiffMatchPatch.PatchDeleteThreshold = 0.5
diff3.DiffMatchPatch.PatchMargin = 4
diff3.DiffMatchPatch.MatchMaxBits = 32

License

MIT

Documentation

Index

Constants

View Source
const (
	// Sep1 signifies the start of a conflict.
	Sep1 = "<<<<<<<"
	// Sep2 signifies the middle of a conflict.
	Sep2 = "======="
	// Sep3 signifies the end of a conflict.
	Sep3 = ">>>>>>>"
)

Variables

View Source
var DiffMatchPatch = diffmatchpatch.New()

DiffMatchPatch contains the diff algorithm settings.

Functions

func Merge

func Merge(textO, textA, textB string) string

Merge implements the diff3 algorithm to merge two texts into a common base.

Types

This section is empty.

Jump to

Keyboard shortcuts

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