From 4292963937018ccd5a0487aebef56d1840f32aff Mon Sep 17 00:00:00 2001 From: Ryan Currah Date: Sun, 5 Apr 2020 17:49:27 -0400 Subject: [PATCH] do not error out when go.mod is missing just raise warning, change linter options --- pkg/golinters/gomodguard.go | 4 +++- pkg/lint/lintersdb/manager.go | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/golinters/gomodguard.go b/pkg/golinters/gomodguard.go index 7dbfe79b..aae78f81 100644 --- a/pkg/golinters/gomodguard.go +++ b/pkg/golinters/gomodguard.go @@ -59,7 +59,9 @@ func NewGomodguard() *goanalysis.Linter { processor, err := gomodguard.NewProcessor(processorCfg, log.New(os.Stderr, "", 0)) if err != nil { - return nil, err + lintCtx.Log.Warnf("running gomodguard failed: %s: if you are not using go modules "+ + "it is suggested to disable this linter", err) + return nil, nil } gomodguardErrors := processor.ProcessFiles(files) diff --git a/pkg/lint/lintersdb/manager.go b/pkg/lint/lintersdb/manager.go index a8aa5e2e..0239f88e 100644 --- a/pkg/lint/lintersdb/manager.go +++ b/pkg/lint/lintersdb/manager.go @@ -249,6 +249,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config { WithURL("https://github.com/tommy-muehle/go-mnd"), linter.NewConfig(golinters.NewGomodguard()). WithPresets(linter.PresetStyle). + WithLoadForGoAnalysis(). WithURL("https://github.com/rcurrah/gomodguard"), }