Using Spacemacs and its go layer.

Using Tramp in Emacs ssh to remote server to edit go file. After saving the file, it will check the syntax with gofmt . But every time it shows the error below:

enter image description here

I have tried install these packages at localhost as official guide:

go get -u -v github.com/nsf/gocode
go get -u -v github.com/rogpeppe/godef
go get -u -v golang.org/x/tools/cmd/guru
go get -u -v golang.org/x/tools/cmd/gorename
go get -u -v golang.org/x/tools/cmd/goimports

go get -u -v github.com/alecthomas/gometalinter
gometalinter --install --update


Also set (go :variables go-use-gometalinter t)(or (setq gofmt-command "goimports")) in the ~/.spacemacs file. But not work. Indeed, there aren't go runtime at remote server where go source exist. So where it looking for and went a alert? How to avoid it?

1 Answer 1


Currently go-mode doesn't support running goimports on a remote host (over tramp). If you just want to stop the error you can disable the before-save-hook that is invoking gofmt:

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

  • Welcome, and thank you for your answer. So you actually want to use remove-hook, isn't it?
    – JeanPierre
    Aug 6, 2019 at 11:16
  • You could use remove-hook, or you could change the code you are using to not add it in the first place.
    – psanford
    Aug 6, 2019 at 15:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.