File tree Expand file tree Collapse file tree 3 files changed +22
-25
lines changed
Expand file tree Collapse file tree 3 files changed +22
-25
lines changed Original file line number Diff line number Diff line change @@ -24,10 +24,17 @@ func (Inspector) CheckDir(dir string) bool {
2424}
2525
2626func (Inspector ) InspectProject (ctx context.Context ) error {
27- if err := buildScan (ctx ); err != nil {
27+ task := model .UseInspectionTask (ctx )
28+ if task .IsNoBuild () {
2829 if err := baseScan (ctx ); err != nil {
2930 return err
3031 }
32+ } else {
33+ if err := buildScan (ctx ); err != nil {
34+ if err := baseScan (ctx ); err != nil {
35+ return err
36+ }
37+ }
3138 }
3239 return nil
3340}
Original file line number Diff line number Diff line change @@ -18,11 +18,25 @@ import (
1818 "golang.org/x/mod/modfile"
1919)
2020
21+ func goModTidy (path string ) error {
22+ _ , err := os .Stat (path )
23+ if err != nil {
24+ cmd := exec .Command ("go" , "mod" , "tidy" )
25+ if err := cmd .Start (); err != nil {
26+ return err
27+ }
28+ }
29+ return nil
30+ }
2131func buildScan (ctx context.Context ) error {
2232 task := model .UseInspectionTask (ctx )
2333 logger := logctx .Use (ctx )
2434 modFilePath := filepath .Join (task .Dir (), "go.mod" )
2535 logger .Debug ("Reading go.mod" , zap .String ("path" , modFilePath ))
36+ if err := goModTidy (filepath .Join (task .Dir (), "go.sum" )); err != nil {
37+ logger .Error ("go mod tidy error :" , zap .Error (err ))
38+ return err
39+ }
2640 modName , err := getModInfo (modFilePath )
2741 if err != nil {
2842 logger .Error ("get mod info error :" , zap .Error (err ))
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments