This module builds on top of the shared Programming
module, as well as the
The following keybindings are set by default, which are not present in each mode's default bindings:
- C-c a (
- C-c m (
- C-c . (
- C-c b (
- C-h f (
Run C-h m for all the key bindings and other documentation.
There are two ways to manage projects in Go:
$GOPATH and with Go
modules. Modules are the newer, recommended method. Read Using Go
Modules to learn about this, if
you are unfamiliar with the subject. Many of the tools used by Prelude
Go may provide functions that are broken with modules. There is
usually another function that will work properly; when in doubt, use a
function provided by
lsp-mode which is documented below.
Generics were added to Go in 1.18.
gopls, the backend for
setup herein, supports generics as long as
gopls itself was built
with 1.18+. Other minor modes may not support generics yet.
prelude-go builds on several useful Go tools, and establishes sensible
defaults. The major mode is
go-mode. Documentation is available at github.com/dominikh/go-mode.el
- Projectile integration
- Switching GOPATH if desired per project (customizable via
- Ability to download all commonly used
gotools via M-x go-projectile-install-tools and update them via M-x go-projectile-update-tools
- Very basic refactoring via
- Support for
go get -uvia
See its documentation for details.
LSP Mode and LSP UI
Server Protocol) is a protocol that allows editors to use an external
"language server" to provide features like autocompletion,
documentation, and code navigation rather than implementing these
features separately in each editor. Emacs supports LSP via
lsp-mode. The language server used is
gopls, change to a directory outside of
$GOPATH or any
/tmp) and execute:
go install golang.org/x/tools/gopls@latest
gopls is in your
Excellent documentation for
lsp-ui are provided at emacs-lsp.github.io/lsp-mode/
If a feature, such as documentation, refactoring, indenting, etc. is
lsp, you should use it instead of calling to another
gopls is the officially maintained tool that supercedes
functionality in other tools, like
gocode, and works properly with
modules and generics.
Company support is automatically added that works with
gotest is also provided
while editing Go files in order to run tests more easily. The bindings
prelude-go are listed at the top because
not set any.