commit | a1a4dd44eb11820695fbe83e00fb2301ee6eb54c | [log] [tgz] |
---|---|---|
author | Aryan Naraghi <aryan.naraghi@gmail.com> | Sun Feb 26 19:44:04 2017 |
committer | GitHub <noreply@github.com> | Sun Feb 26 19:44:04 2017 |
tree | 776fc7240b2b23b5ddd155e2a3e4f4a2a02e18ba | |
parent | 776c10554c595258f0e677fce730371bf0950141 [diff] | |
parent | 16e84ecf54cfad20b518b32c1bff04478dc7cb56 [diff] |
Merge pull request #4 from bozaro/line-num Add lost `line-num` style to deleted lines
difflib is a simple library written in Go for diffing two sequences of text.
To install, issue:
go get github.com/aryann/difflib
To start using difflib, create a new file in your workspace and import difflib:
import ( ... "fmt" "github.com/aryann/difflib" ... )
Then call either difflib.Diff
or difflib.HTMLDiff
:
fmt.Println(difflib.HTMLDiff([]string{"one", "two", "three"}, []string{"two", "four", "three"}))
If you'd like more control over the output, see how the function HTMLDiff
relies on Diff
in difflib.go.
There is a demo application in the difflib_demo directory. To run it, navigate to your $GOPATH
and run:
go run src/github.com/aryann/difflib/difflib_server/difflib_demo.go <file-1> <file-2>
Where <file-1>
and <file-2>
are two text files you'd like to diff. The demo will launch a web server that will contain a table of the diff results.