prep Install golangci-lint
$ cd ~/go
# go mod がないと install 出来ない
$ curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $(go env GOPATH)/bin v1.20.0
# version その時その時で
# wite your golangci-lint configuration
$ touch ~/go/golangci-lint.yaml
eg (see .golangci.example.yml)
# This file contains all available configuration options
# with their default values.
# options for analysis running
run:
# default concurrency is a available CPU number
concurrency: 2
# timeout for analysis, e.g. 30s, 5m, default is 1m
timeout: 1m
linters:
enable:
- deadcode
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- structcheck
- typecheck
- unused
- varcheck
- gocyclo
- gosimple
disable-all: true
presets:
- bugs
- unused
fast: false
install emacs packages
M-x package-install flycheck
M-x package-install fly-golangci-lint
init.el
;;; package install で生成されたもの
(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.
'(package-selected-packages
(quote
(go-mode flycheck-golangci-lint flycheck)))
'(tool-bar-mode nil))
(custom-set-faces
;; custom-set-faces 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.
)
;;; 公式サイトからコピペ
(eval-after-load 'flycheck
'(add-hook 'flycheck-mode-hook #'flycheck-golangci-lint-setup))
(setq flycheck-golangci-lint-config "~/go/golangci-lint.yaml") ;; lint の設定ファイル
(add-hook 'go-mode-hook 'flycheck-mode) ;; go-modeでflycheckを利用するように