Skip to content

exhaustructは型リテラルごとにデフォルトの挙動と個別の挙動を変えられる

This content is a draft and will not be included in production builds.

以下の記事より

グローバルな設定のほかに、リテラルごとに挙動を変更できる。

//exhaustruct:enforce
return &User{Name: "user"}

または末尾でもいい

return &User{} // exhaustruct:ignore

型ごとに enforce または ignore を指定したい場合は include ディレクティブ(-i オプション)や exclude ディレクティブ(-e オプション)で正規表現を使って指定する。デフォルトはすべて対象とするので、最初は exclude しておいて個別に exhaustruct:enforce すると便利だろう。

linters:
enable:
- exhaustruct
settings:
exhaustruct:
exclude:
- '.+'
include:
- 'github\.com/lufia/dotsync/.*'

公式のドキュメントにも書いてある。