Note: All contributions to go-mode that do not affect the README should follow the guidelines at http://golang.org/doc/contribute.html
This is go-mode as it ships with Go since Go 1.1. It's a replacement for and full rewrite of the old go-mode that shipped with Go 1.0.3 and before.
From the point of view of its primary developer, this is the main repository. Strictly speaking, however, go-mode is part of the Go distribution (and therein refered to as misc/emacs), and the canonical location is at http://code.google.com/p/go/source/browse#hg%2Fmisc%2Femacs – Nevertheless, new developments, if they are not 3rd party contributions, will be made available here first.
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:
- Integration with
gofmt
by providing a command of the same name, andgofmt-before-save
, which can be used in a hook to format Go buffers before saving them.- Setting the
gofmt-command
variable also allows usinggoimports
.
- Setting the
- Integration with
godoc
via the functionsgodoc
andgodoc-at-point
. - Integration with the Playground
go-play-buffer
andgo-play-region
to send code to the Playgroundgo-download-play
to download a Playground entry into a new buffer
- Managing imports
- A function for jumping to the file's imports (
go-goto-imports
) - A function for adding imports, including tab completion
(
go-import-add
, bound toC-c C-a
) - A function for removing or commenting unused imports
(
go-remove-unused-imports
)
- A function for jumping to the file's imports (
- Integration with godef
godef-describe
(C-c C-d
) to describe expressionsgodef-jump
(C-c C-j
) andgodef-jump-other-window
(C-x 4 C-c C-j
) to jump to declarations- This requires you to install godef via
go get code.google.com/p/rog-go/exp/cmd/godef
.
- Basic support for imenu (functions and variables)
- Built-in support for displaying code coverage as calculated by
go test
(go-coverage
)
There are several third party extensions that can enhance the Go experience in Emacs.
There are two ways of using flymake with Go:
- goflymake, which internally
uses
go build
to capture all errors that a regular compilation would also produce - flymake-go for a
more lightweight solution that only uses
gofmt
and 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
using go build
or gofmt
, it also has support for go vet
,
golint
and errcheck
.
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. Also, go-mode is part of the official Go distribution. Donations would be towards me, Dominik Honnef, and not go-mode as a whole.
Because go-mode.el is also part of the Go distribution, there are essentially two ways to contribute changes:
- By sending a pull request on GitHub
- By submitting a CL to the Go project
Because of copyright reasons, I will not accept any non-trivial contributions via pull requests. Please submit a CL instead. This will ensure that the changes go through a proper review process and that your name will be noted in the list of contributors and possibly authors. Instructions can be found at http://golang.org/doc/contribute.html.
Only changes to files that are not part of the Go distribution (mainly this README), can be submitted via pull request.