www.github.com/golangci/golangci-lint.git@v1.10.1/pkg/commands/linters.go (about) 1 package commands 2 3 import ( 4 "log" 5 "os" 6 7 "github.com/fatih/color" 8 "github.com/golangci/golangci-lint/pkg/lint/linter" 9 "github.com/golangci/golangci-lint/pkg/lint/lintersdb" 10 "github.com/spf13/cobra" 11 ) 12 13 func (e *Executor) initLinters() { 14 lintersCmd := &cobra.Command{ 15 Use: "linters", 16 Short: "List current linters configuration", 17 Run: e.executeLinters, 18 } 19 e.rootCmd.AddCommand(lintersCmd) 20 e.initRunConfiguration(lintersCmd) 21 } 22 23 func IsLinterInConfigsList(name string, linters []linter.Config) bool { 24 for _, linter := range linters { 25 if linter.Linter.Name() == name { 26 return true 27 } 28 } 29 30 return false 31 } 32 33 func (e Executor) executeLinters(cmd *cobra.Command, args []string) { 34 enabledLCs, err := lintersdb.GetEnabledLinters(e.cfg, e.log.Child("lintersdb")) 35 if err != nil { 36 log.Fatalf("Can't get enabled linters: %s", err) 37 } 38 39 color.Green("Enabled by your configuration linters:\n") 40 printLinterConfigs(enabledLCs) 41 42 var disabledLCs []linter.Config 43 for _, lc := range lintersdb.GetAllSupportedLinterConfigs() { 44 if !IsLinterInConfigsList(lc.Linter.Name(), enabledLCs) { 45 disabledLCs = append(disabledLCs, lc) 46 } 47 } 48 49 color.Red("\nDisabled by your configuration linters:\n") 50 printLinterConfigs(disabledLCs) 51 52 os.Exit(0) 53 }