Skip to content

daviddengcn/go-diff

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

72 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-diff GoSearch

A diff tool for Go languange. It shows the semantic differences between two Go source files.

Ignored Difference

  1. Order of import statements
  2. Order of definitions of global type/const/var/func
  3. Whether more than one parameters or global variables are declared in one line. e.g. var a, b int = 1, 2 is equivalent to var a int = 1; var b int = 2. (NOTE parallel assignments are not normalized)
  4. All comments.
  5. Code formats. e.g. some useless new lines.

Other Features

  1. Smart matching algorithm on go ast tree.
  2. If a function is deleted or added as a whole, only one-line message is shown (starting by === or ###)
  3. Easily see which function or type, etc. the difference is in.
  4. Import/const/var/func diffrences are shown in order, independent of the lines' order in the source.
  5. Token based line-line difference presentation.

Installation

$ go get -u github.com/daviddengcn/go-diff
$ go install github.com/daviddengcn/go-diff
$ go-diff <old-file> <new-file>

(Make sure $GO_PATH/bin is in system's $PATH)

Used as git diff

  1. Link scripts/go-diff.gs (you need install gosl) or scripts/go-diff.sh to a folder in PATH

  2. Set Git external diff driver (change go-diff.gs to go-diff.sh accordingly if necessary)

$ git config [--global] diff.external go-diff.gs
$ git diff

License

BSD license

About

A diff tool especially for Go language.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages