From 70e7b8a38898275e84bc35db50dea409ce4fb6cc Mon Sep 17 00:00:00 2001 From: Gerry Agbobada Date: Wed, 30 Oct 2019 09:36:05 +0100 Subject: [PATCH] Add flycheck-golangci-lint This plugin runs [golangci-lint](https://github.com/golangci/golangci-lint) in the background and gathers the results in a checker. --- modules/lang/go/README.org | 6 ++++++ modules/lang/go/config.el | 5 +++++ modules/lang/go/packages.el | 3 +++ 3 files changed, 14 insertions(+) diff --git a/modules/lang/go/README.org b/modules/lang/go/README.org index 916c9abdd..77299db90 100644 --- a/modules/lang/go/README.org +++ b/modules/lang/go/README.org @@ -27,6 +27,7 @@ This module adds [[https://golang.org][Go]] support. + [[../../editor/file-templates/templates/go-mode][File templates]] + [[https://github.com/hlissner/doom-snippets/tree/master/go-mode][Snippets]] + Generate testing code (~go-gen-test~) ++ Code checking (~flycheck-golangci-lint~) ** Module Flags This module provides no flags. @@ -39,6 +40,7 @@ This module provides no flags. + [[https://github.com/syohex/emacs-go-add-tags][go-add-tags]] + [[https://github.com/mdempsky/gocode][company-go]]* + [[https://github.com/s-kostyaev/go-gen-test][go-gen-test]] ++ [[https://github.com/weijiangan/flycheck-golangci-lint][flycheck-golangci-lint]] (if =:tools flycheck= is enabled) * Prerequisites ** Go @@ -82,6 +84,10 @@ go get -u golang.org/x/tools/cmd/guru go get -u github.com/cweill/gotests/... #+END_SRC ++ ~golangci-lint~ (optional: for flycheck to integrate golangci-lint results) + it is recommended to *not* use go get to install this one, check the + [[https://github.com/golangci/golangci-lint#binary-release][documentation]]. + * TODO Features * TODO Configuration diff --git a/modules/lang/go/config.el b/modules/lang/go/config.el index 0c13afd68..eae47576f 100644 --- a/modules/lang/go/config.el +++ b/modules/lang/go/config.el @@ -68,3 +68,8 @@ :config (set-company-backend! 'go-mode 'company-go) (setq company-go-show-annotation t)) + +(use-package! flycheck-golangci-lint + :when (featurep! :tools flycheck) + :hook (go-mode . flycheck-golangci-lint-setup) + :config (setenv "GO111MODULE" "on")) diff --git a/modules/lang/go/packages.el b/modules/lang/go/packages.el index bbf22ba0b..5203311e2 100644 --- a/modules/lang/go/packages.el +++ b/modules/lang/go/packages.el @@ -10,3 +10,6 @@ (when (featurep! :completion company) (package! company-go)) + +(when (featurep! :tools flycheck) + (package! flycheck-golangci-lint))