File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,7 +3,6 @@ package project
33import (
44 "log"
55 "os"
6- "os/exec"
76 "path/filepath"
87 "regexp"
98 "sort"
@@ -58,8 +57,7 @@ func checkDirsNested(inputDirs []string) (string, bool) {
5857func initGoModForLegacyProject (path string ) {
5958 log .Printf ("Project appears to be a legacy Go project, attempting to initialize go.mod" )
6059
61- modInit := exec .Command ("go" , "mod" , "init" , "codeql/auto-project" )
62- modInit .Dir = path
60+ modInit := toolchain .InitModule (path )
6361
6462 if ! util .RunCmd (modInit ) {
6563 log .Printf ("Failed to initialize go.mod file for this project." )
Original file line number Diff line number Diff line change @@ -78,3 +78,10 @@ func TidyModule(path string) *exec.Cmd {
7878 cmd .Dir = path
7979 return cmd
8080}
81+
82+ // Run `go mod init` in the directory given by `path`.
83+ func InitModule (path string ) * exec.Cmd {
84+ modInit := exec .Command ("go" , "mod" , "init" , "codeql/auto-project" )
85+ modInit .Dir = path
86+ return modInit
87+ }
You can’t perform that action at this time.
0 commit comments