Note: This go-mode.el has been merged upstream and is now part of the Go distribution. New features and bugfixes will be made available here first, but will be sent upstream as well.
This is a replacement for the old Go mode that came with the Go distribution <= v1.0.3. It fixes several issues and adds new features, such as movement by functions, like one is used to from other major modes in emacs.
- Uses a proper syntax table, so that emacs and other packages know about strings and comments (e.g. expand-region needs this)
- Fixes various indentation/font locking problems caused by the lack of proper syntax table
- Fixes gofmt issue with buffers that do not end with a newline
- Does not fontify anonymous functions as if they were methods
- Fontifies
(foo)(bar)
function calls - Fontifies identifiers with unicode characters in them
- Fontifies type names in struct literals
- Fontifies type names in maps, slices and arrays
- Uses view-mode for the godoc buffer
- Complete rewrite of gofmt, fixing several issues
- Support for
C-M-a
(beginning-of-defun
),C-M-e
(end-of-defun
) and all functions that make use of defun navigation, such asC-M-h
(mark-defun
),C-x n d
(narrow-to-defun
) and more. - Two functions for sending code to the Playground (
go-play-buffer
andgo-play-region
) - A function for downloading code from the Playground into a Go buffer (
go-download-play
) - 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
) godef-describe
andgodef-jump
(C-c C-d
andC-c C-j
) to describe expressions and jump to their declarations. This requires you to install godef viago get code.google.com/p/rog-go/exp/cmd/godef
.- Adds basic support for imenu (functions and variables)
- Built-in support for displaying code coverage as calculated by go test (
go-coverage
)
For a richer experience, consider installing goflymake for on-the-fly syntax checking and gocode for auto completion.
Alternatively there is also flymake-go, which uses gofmt to check for syntax errors and doesn't require installing any additional binaries. It only catches syntactic errors though.
Also, if you're using YASnippet, consider using the snippets from yasnippet-go.
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.
Trivial changes, and changes to files that are not part of the Go distribution (mainly this README), can be submitted via pull request.