mirror of
https://github.com/github/codeql.git
synced 2026-04-21 06:55:31 +02:00
Go: Initialise go.mod for stray source files
This commit is contained in:
@@ -301,6 +301,7 @@ func getBuildRoots(emitDiagnostics bool) (goWorkspaces []GoWorkspace, totalModul
|
||||
goWorkspaces = []GoWorkspace{{
|
||||
BaseDir: ".",
|
||||
DepMode: GoGetWithModules,
|
||||
Modules: loadGoModules([]string{"go.mod"}),
|
||||
ModMode: getModMode(GoGetWithModules, "."),
|
||||
}}
|
||||
totalModuleFiles = 1
|
||||
@@ -324,12 +325,16 @@ func getBuildRoots(emitDiagnostics bool) (goWorkspaces []GoWorkspace, totalModul
|
||||
diagnostics.EmitGoFilesOutsideGoModules(goModPaths)
|
||||
}
|
||||
|
||||
goWorkspaces = []GoWorkspace{{
|
||||
// Try to initialize a `go.mod` file automatically for the stray source files.
|
||||
initGoModForLegacyProject(".")
|
||||
|
||||
goWorkspaces = append(goWorkspaces, GoWorkspace{
|
||||
BaseDir: ".",
|
||||
DepMode: GoGetNoModules,
|
||||
Modules: loadGoModules([]string{"go.mod"}),
|
||||
DepMode: GoGetWithModules,
|
||||
ModMode: ModUnset,
|
||||
}}
|
||||
totalModuleFiles = 0
|
||||
})
|
||||
totalModuleFiles += 1
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
extractedFiles
|
||||
| src/go.mod:0:0:0:0 | src/go.mod |
|
||||
| src/main.go:0:0:0:0 | src/main.go |
|
||||
| src/subdir/go.mod:0:0:0:0 | src/subdir/go.mod |
|
||||
| src/subdir/subsubdir/add.go:0:0:0:0 | src/subdir/subsubdir/add.go |
|
||||
| src/subdir/test.go:0:0:0:0 | src/subdir/test.go |
|
||||
#select
|
||||
| Extraction failed in subdir/test.go with error cannot find package "subdir/subsubdir" in any of:\n\t(absolute path) (from $GOROOT)\n\t(absolute path) (from $GOPATH) | 2 |
|
||||
| Extraction failed in subdir/test.go with error could not import subdir/subsubdir (invalid package name: "") | 2 |
|
||||
|
||||
Reference in New Issue
Block a user