Skip to content

Commit c766f68

Browse files
committed
Fix bug detecting if go.mod files are nested
1 parent 1a80ba0 commit c766f68

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

go/extractor/cli/go-autobuilder/go-autobuilder.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,16 @@ func getDirs(paths []string) []string {
249249
return dirs
250250
}
251251

252-
// Note this has the side effect of sorting `dirs`
253-
func checkDirsNested(dirs []string) bool {
252+
func checkDirsNested(inputDirs []string) bool {
253+
// replace "." with "" so that we can check if all the paths are nested
254+
dirs := make([]string, len(inputDirs))
255+
for i, inputDir := range inputDirs {
256+
if inputDir == "." {
257+
dirs[i] = ""
258+
} else {
259+
dirs[i] = inputDir
260+
}
261+
}
254262
// the paths were generated by a depth-first search so I think they might
255263
// be sorted, but we sort them just in case
256264
sort.Strings(dirs)

go/ql/integration-tests/all-platforms/go/two-go-mods-one-in-root/diagnostics.expected

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"severity": "note",
44
"source": {
55
"extractorName": "go",
6-
"id": "go/autobuilder/multiple-go-mod-found-not-nested",
7-
"name": "Multiple `go.mod` files found, not all nested under one root `go.mod` file"
6+
"id": "go/autobuilder/multiple-go-mod-found-nested",
7+
"name": "Multiple `go.mod` files were found, all nested under one root `go.mod` file"
88
},
99
"visibility": {
1010
"cliSummaryTable": false,

0 commit comments

Comments
 (0)