git clone 'git://github.com/dominikh/go-mode.el.git'
This is go-mode, the Emacs mode for editing Go code.
It is a complete rewrite of the go-mode that shipped with Go 1.0.3 and before, and was part of Go 1.1 until Go 1.3. Beginning with Go 1.4, editor integration will not be part of the Go distribution anymore, making this repository the canonical place for go-mode.
In addition to normal features, such as fontification and indentation,
and close integration with familiar Emacs functionality (for example
syntax-based navigation like
beginning-of-defun), go-mode comes with
the following extra features to provide an improved experience:
gofmtby providing a command of the same name, and
gofmt-before-save, which can be used in a hook to format Go buffers before saving them.
gofmt-commandvariable also allows using
godocvia the functions
go-play-regionto send code to the Playground
go-download-playto download a Playground entry into a new buffer
go-import-add, bound to
C-c C-d) to describe expressions
C-c C-j) and
C-x 4 C-c C-j) to jump to declarations
go get code.google.com/p/rog-go/exp/cmd/godef.
The recommended way of installing go-mode is via ELPA, the Emacs package manager, and the MELPA repository, which provides an up-to-date version of go-mode.
If you're not familiar with ELPA yet, consider reading this guide.
To install go-mode manually, place
go-mode-autoloads.el in a directory of your choice, add it to your
load path and require
(add-to-list 'load-path "/place/where/you/put/it/") (require 'go-mode-autoloads)
Either evaluate both statements with
C-x C-e, or restart Emacs.
As a side note, normally the autoloads file shouldn't be part of the
package, as it's supposed to be automatically generated by ELPA, or
manually by the user with
update-file-autoloads. go-mode includes
said file because it used to when it was part of the Go distribution
and this makes upgrading easier for some people.
There are several third party extensions that can enhance the Go experience in Emacs.
There are two ways of using flymake with Go:
go buildto capture all errors that a regular compilation would also produce
gofmtand as such is only able to catch syntax errors. Unlike goflymake, however, it does not require an additional executable.
Additionally, there is
flycheck, a modern replacement
for flymake, which comes with built-in support for Go. In addition to
go build or
gofmt, it also has support for
For auto completion, take a look at gocode.
https://github.com/syohex/emacs-go-eldoc provides eldoc functionality for go-mode.
I maintain a set of YASnippet snippets for go-mode at https://github.com/dominikh/yasnippet-go
https://github.com/dominikh/go-errcheck.el provides integration with errcheck.
I am accepting donations for go-mode, but it has to be said that even though I am its primary developer, there are several third party contributions with varying complexity. Donations would be towards me, Dominik Honnef, and not go-mode as a whole.