LoginSignup
4
6

More than 5 years have passed since last update.

GoLand で linter を有効にする

Posted at

はじめに

  • GoLand でファイルのセーブ時に go fmt, goimports, gometalinter を有効にする手順

バージョン

  • GoLand 2018.2.2

手順

  • メニューの GoLand > Preferences > Tools > File Watchers を開く
  • + を押下しデフォルトで用意されている go fmt, goimports, gometalinter を追加する
    • 未インストールであればインストールするウィザードが出るのでそのままインストールする
    • gometalinter は各種 linter のラッパーなので、インストール後にターミナルから gometalinter -i を実行し、利用している linter をインストールする

gometalinter の設定

  • gometalinter はデフォルトでは多数の linter を実行するのでそこそこ重くなる
  • File Watchers の設定で Arguments に必要な linter だけを有効にするよう引数で指定すると使いやすくなる

デフォルトの引数(実行時間 20sec 程度)
--vendor --fast --enable-gc --tests --aggregate --disable=gotype $FileDir$

軽量化した引数(参考までに)(実行時間 2sec 程度)
--vendor --fast --enable-gc --tests --aggregate --disable=gotype --disable=gosec --disable=gocyclo --disable=vetshadow $FileDir$

4
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
6