lang/go: relax warnings

+ Don't default to goimports unless it's available.
+ No warning if goimports is missing.
This commit is contained in:
Henrik Lissner 2018-02-14 05:52:07 -05:00
parent 57adae5ec6
commit 38903d07e8
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -4,13 +4,8 @@
:mode "\\.go$"
:interpreter "go"
:config
(add-hook 'go-mode-hook #'flycheck-mode)
(setq gofmt-command "goimports"
gofmt-show-errors nil)
(if (not (executable-find "goimports"))
(warn "go-mode: couldn't find goimports; no code formatting/fixed imports on save")
(add-hook! go-mode (add-hook 'before-save-hook #'gofmt-before-save nil t)))
(when (executable-find "goimports")
(setq gofmt-command "goimports"))
(set! :repl 'go-mode #'gorepl-run)
(set! :lookup 'go-mode
@ -18,6 +13,11 @@
:references #'go-guru-referrers
:documentation #'godoc-at-point)
(setq gofmt-show-errors nil) ; Leave it to flycheck
(add-hook 'go-mode-hook #'flycheck-mode)
(add-hook! go-mode
(add-hook 'before-save-hook #'gofmt-before-save nil t))
(def-menu! +go/refactor-menu
"Refactoring commands for `go-mode' buffers."
'(("Add import" :exec go-import-add :region nil)