since diff is a command only available in bash, the binary formed by building the above code cannot be used to get diff in a Windows system
It can, if you install (unzip anywhere you want) the latest Portable Git (like PortableGit-2.14.1-64-bit.7z.exe
)
If you add that installation to your PATH, you do have diff (to be used in your Go program)
vonc@VONCAVN7 C:\
> where diff
D:\prgs\git\latest\usr\bin\diff.exe
But if you don't want to rely on an existing thrid-party installed software (here Git), you might consider vendoring in your project spcau/godiff
.
If does have a diff
implementation for Windows.
Note that, with Git 2.17 (Q2 2018), Go is better recognized by Git, since "git diff
" and friends learned funcname
patterns for Go language source files.
See commit 1dbf0c0 (01 Mar 2018) by Alban Gruin (``).
(Merged by Junio C Hamano -- gitster
-- in commit 077cde9, 08 Mar 2018)
userdiff
: add built-in pattern for Golang
This adds xfuncname
and word_regex
patterns for Golang, a quite
popular programming language. It also includes test cases for the
xfuncname
regex (t4018) and updated documentation.
The xfuncname
regex finds functions, structs and interfaces.
Although the Go language prohibits the opening brace from being on its own
line, the regex does not makes it mandatory, to be able to match
func
statements like this:
func foo(bar int,
baz int) {
}
This is covered by the test case t4018/golang-long-func
.
The word_regex
pattern finds identifiers, integers, floats, complex
numbers and operators, according to the go specification.