File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,8 @@ func setupLintersFlagSet(v *viper.Viper, fs *pflag.FlagSet) {
2828 fs .StringSliceP ("presets" , "p" , nil ,
2929 color .GreenString (fmt .Sprintf ("Enable presets (%s) of linters. Run 'golangci-lint help linters' to see " +
3030 "them. This option implies option --disable-all" , strings .Join (lintersdb .AllPresets (), "|" ))))
31+
32+ fs .StringSlice ("only" , nil , color .GreenString ("Override linters configuration section to only run the specific linter(s)" )) // Flags only.
3133}
3234
3335func setupRunFlagSet (v * viper.Viper , fs * pflag.FlagSet ) {
Original file line number Diff line number Diff line change @@ -61,6 +61,31 @@ func (l *Loader) Load() error {
6161
6262 l .handleGoVersion ()
6363
64+ err = l .handleOnlyOption ()
65+ if err != nil {
66+ return err
67+ }
68+
69+ return nil
70+ }
71+
72+ func (l * Loader ) handleOnlyOption () error {
73+ only , err := l .fs .GetStringSlice ("only" )
74+ if err != nil {
75+ return err
76+ }
77+
78+ if len (only ) > 0 {
79+ l .cfg .Linters = Linters {
80+ Enable : only ,
81+ Disable : nil ,
82+ EnableAll : false ,
83+ DisableAll : true ,
84+ Fast : false ,
85+ Presets : nil ,
86+ }
87+ }
88+
6489 return nil
6590}
6691
You can’t perform that action at this time.
0 commit comments