Use gometalinter if present.

This commit is contained in:
JAremko 2016-04-11 17:08:56 +03:00 committed by syl20bnr
parent d995f39e07
commit ae512ee8f1
2 changed files with 32 additions and 1 deletions

View File

@ -23,6 +23,7 @@ This layer adds extensive support for go.
- gofmt/goimports on file save
- Auto-completion using [[https://github.com/nsf/gocode/tree/master/emacs][go-autocomplete]] (with the =auto-completion= layer)
- Source analysis using [[http://golang.org/s/oracle-user-manual][go-oracle]]
- Linting with flycheck's built-in checkers or flycheck-gometalinter
* Install
** Pre-requisites
@ -36,6 +37,16 @@ You will need =gocode= and =godef=:
go get -u -v golang.org/x/tools/cmd/goimports
#+END_SRC
If you wish to use =gometalinter=:
#+BEGIN_SRC sh
go get -u -v github.com/alecthomas/gometalinter
gometalinter --install --update
#+END_SRC
For more information read [[https://github.com/alecthomas/gometalinter/blob/master/README.md][gometalinter README.md]]
and [[https://github.com/favadi/flycheck-gometalinter/blob/master/README.md][flycheck-gometalinter README.md]]
Make sure that =gocode= executable is in your PATH. For information about
setting up =$PATH=, check out the corresponding section in the FAQ (~SPC h SPC
$PATH RET~).

View File

@ -3,6 +3,7 @@
company
company-go
flycheck
flycheck-gometalinter
go-eldoc
go-mode
(go-oracle :location site)
@ -10,7 +11,22 @@
))
(defun go/post-init-flycheck ()
(spacemacs/add-flycheck-hook 'go-mode))
(spacemacs/add-flycheck-hook 'go-mode)
(defun spacemacs//go-gometalinter-maybe-enable ()
"Enable `flycheck-gometalinter' and disable overlapping `flycheck' linters
if gometalinter executable is found."
(when (executable-find "gometalinter")
(setq flycheck-disabled-checkers '(go-gofmt
go-golint
go-vet
go-build
go-test
go-errcheck)))
(flycheck-gometalinter-setup))
(add-hook 'go-mode-hook 'spacemacs//go-gometalinter-maybe-enable) t)
(defun go/init-go-mode()
(when (memq window-system '(mac ns x))
@ -134,3 +150,7 @@
(use-package go-rename
:init
(spacemacs/set-leader-keys-for-major-mode 'go-mode "rn" 'go-rename)))
(defun go/init-flycheck-gometalinter()
(use-package flycheck-gometalinter
:defer t))