0

My flycheck checkers don't get along well.

To simplify things I've reduced the flycheck-checkers list to only

go-build
golangci-lint

But even now behavior is weird:

  • syntax errors only show up right after saving the file.
  • syntax errors will disappear as soon as the buffer is modified even if the code still isn't valid.
  • lint errors only show up a moment after modifying a saved file but the errors seem to refer to the saved file's contents not the modified content

I'm on debian stretch emacs24-nox with flycheck, go-dlv, goeldoc, go-mode installed from melpa and this golangci-lint flycheck integration (as suggested by the golangci-lint people. https://raw.githubusercontent.com/weijiangan/flycheck-golangci-lint/master/flycheck-golangci-lint.el

I have dlv, gocode, godef, goimports, golangci-lint, and golint installed in my path and go1.12.9

Relevant parts of my init.el edited for brevity:

(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(flycheck-checkers (quote (go-build golangci-lint)) nil nil "This is such a hack. I can't figure out flycheck for now this will have to do!")
 '(flycheck-go-vet-executable "true")
 '(flycheck-golangci-lint-enable-all nil) ;; because go tool vet is deprecated
)

;; Flycheck
(defvar myPackages
  '(better-defaults
    elpy
    flycheck ;; add the flycheck package
    material-theme))
(when (require 'flycheck nil t)
  (setq elpy-modules (delq 'elpy-module-flymake elpy-modules))
  (add-hook 'go-mode-hook  'flycheck-mode)
  (add-hook 'elpy-mode-hook 'flycheck-mode))

;;; go-mode go-eldoc
(setq gofmt-command "goimports")
(add-hook 'go-mode-hook 'go-eldoc-setup)
(add-hook 'go-mode-hook
          (lambda ()
            ;; gofmt before save
            (add-hook 'before-save-hook 'gofmt-before-save)
            ;; godef jump back from function C-c C-j
            (local-set-key (kbd "C-c C-k") 'pop-tag-mark)
            ;; Customize compile command to run go build
            (if (not (string-match "go" compile-command))
                (set (make-local-variable 'compile-command)
                     "go build -v && go test -v && go vet"))
            (setq tab-width 4)))

;;; golint
(add-to-list 'load-path (concat (getenv "GOPATH")  "/src/golang.org/x/lint/misc/emacs/"))
(require 'golint)
;;; golangci-lint
(require 'flycheck-golangci-lint)
(eval-after-load 'flycheck
  '(add-hook 'flycheck-mode-hook #'flycheck-golangci-lint-setup))

;;; auto-complete (needed by go autocomplete)
;; gocode autocomplete
(require 'go-autocomplete)
(require 'auto-complete-config)
(ac-config-default)

I'd really like to enable more checkers like this:

go-gofmt                     
go-golint                    
go-vet                       
go-build                     
go-test                      
go-errcheck                  
go-unconvert                 
go-megacheck                 
golangci-lint

But if i can't even get go-build and golangci-lint to play along well I'm really up a creek.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.