Clone this repo:


  1. a1a4dd4 Merge pull request #4 from bozaro/line-num by Aryan Naraghi · 4 months ago master
  2. 776c105 Merge pull request #3 from udhos/master by Aryan Naraghi · 4 months ago
  3. 16e84ec Add lost `line-num` style to deleted lines by Artem V. Navrotskiy · 4 months ago
  4. 9237ff6 godoc badge. by Everton Marques · 4 months ago
  5. 5c6536b Merge pull request #1 from aryann/master by udhos · 4 months ago



difflib is a simple library written in Go for diffing two sequences of text.


To install, issue:

go get


To start using difflib, create a new file in your workspace and import difflib:

import (

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.

Running the Demo

There is a demo application in the difflib_demo directory. To run it, navigate to your $GOPATH and run:

go run src/ <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.