Search code examples
goemacsgofmt

Emacs Golang gofmt on save hook - not formatting


after checking path with M-: (eval "PATH") the location of C:/Go/bin shows up, so I know the binary is found. If i try to do M-x gofmt on other files it will give proper errors (not *.go files).

however I noticed something weird in the Messages which is where the gofmt is trying to format..

Calling gofmt: gofmt (-w c:/Users/LunchBox/AppData/Local/Temp/gofmt5200q9o.go)
Error: (file-error "Searching for program" "no such file or directory" "diff")

why is it looking in the -w /appdata/locals/temp/etc..?
shouldn't it be the file I'm working on currently? which is just called ovRESTful.go in c:/work/users/ovRESTful/ovRESTful.go

the line I have for my code..

(add-hook 'before-save-hook 'gofmt-before-save)

Solution

  • diff is the name of a command to compare files line by line which is usually distributed with unix-derived operating systems.

    You could try to install these utilities on windows:

    http://gnuwin32.sourceforge.net/packages/diffutils.htm

    to see if that helps.