A diff tool for Go languange. It shows the semantic differences between two Go source files.
- Order of
import
statements - Order of definitions of global
type
/const
/var
/func
- Whether more than one parameters or global variables are declared in one line. e.g.
var a, b int = 1, 2
is equivalent tovar a int = 1; var b int = 2
. (NOTE parallel assignments are not normalized) - All comments.
- Code formats. e.g. some useless new lines.
- Smart matching algorithm on go ast tree.
- If a function is deleted or added as a whole, only one-line message is shown (starting by
===
or###
) - Easily see which function or type, etc. the difference is in.
- Import/const/var/func diffrences are shown in order, independent of the lines' order in the source.
- Token based line-line difference presentation.
$ go get -u github.com/daviddengcn/go-diff
$ go install github.com/daviddengcn/go-diff
$ go-diff <new-file> <org-file>
(Make sure $GO_PATH/bin
is in system's $PATH
)
Used as git diff
$ git config [--global] diff.external go-diff
$ git diff
BSD license