Go Projectile is a set of Go language related add-ons for the Emacs Projectile mode.
(require 'go-projectile)
After running projectile-switch-project
(C-c p s) the features of
go-projectile
will be (optionally) enabled.
Rather than have a global GOPATH set in your .bashrc or similar, go-projectile
makes it easier for each project to have their own GOPATH automatically
configured. Upon switching to a projectile project, the GOPATH environment
variable will be set appropriately, see go-projectile-switch-gopath
.
The go-projectile-set-gopath
function can also be called directly, without
using projectile-switch-project
.
Most of the Emacs Go packages have hard or soft dependencies on
programs installed via go get
, such as gocode
, godef
, etc.
You can install the complete set of go-projectile-tools
using:
M-x go-projectile-install-tools
And update the tools using: M-x go-projectile-update-tools
These tools are installed within their own GOPATH, configurable via
the go-projectile-tools-path
variable.
Run vc-git-grep
on *.go
in the $GOPATH/src/
directory of the
current buffer using go-projectile-git-grep
(C-c p G).
Useful for use within multi-language projects and/or repositories that include vendored packages.
Create a new projectile project via go-projectile-get
(C-c p N).
This function will 'go get' an existing repo and switch to the new project.
Renaming of Go identifiers is available via go-rename
(C-c p w).
Very basic refactoring is made available via go-projectile-rewrite
(C-c p W).
It is just a wrapper around gofmt -r
, where go-projectile tries to help
generate the rewrite pattern based on the cursor's location. The rewrite rule
will only apply to '*.go' files in the current project, excluding patterns
listed in `go-project-files-ignore'.