Skip to content

ncalabro18/go_differ

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go Diff Algorithm

Build Status codecov

An implementation of the Myers' Greedy Algorithm. In addition, there is a utility to quickly use edit scripts for recording deltas.

Install

go get github.com/ncalabro18/go_differ.git

Example

import (
	"fmt"
	"github.com/ncalabro18/go_differ.git/godiff/v1"
)

func main() {
	f1 := []byte("ABCABBA")
	f2 := []byte("CBABAC")

	d := godiff.NewDelta(f1, f2) //creates the delta script to convert f1 + d -> f2
	scriptResult := d.F2()       //runs the script, f1 is stored in Delta structure
	fmt.Println(string(scriptResult))
}

Output:

CBABAC

About

Myers' Greedy Diff Algorithm in Golang

Resources

Stars

Watchers

Forks

Languages