File tree Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -249,7 +249,7 @@ func getDirs(paths []string) []string {
249
249
return dirs
250
250
}
251
251
252
- func checkDirsNested (inputDirs []string ) bool {
252
+ func checkDirsNested (inputDirs []string ) ( string , bool ) {
253
253
// replace "." with "" so that we can check if all the paths are nested
254
254
dirs := make ([]string , len (inputDirs ))
255
255
for i , inputDir := range inputDirs {
@@ -264,10 +264,10 @@ func checkDirsNested(inputDirs []string) bool {
264
264
sort .Strings (dirs )
265
265
for _ , dir := range dirs {
266
266
if ! strings .HasPrefix (dir , dirs [0 ]) {
267
- return false
267
+ return "" , false
268
268
}
269
269
}
270
- return true
270
+ return dirs [ 0 ], true
271
271
}
272
272
273
273
// Returns the directory to run the go build in and whether to use a go.mod
@@ -290,15 +290,20 @@ func findGoModFiles(emitDiagnostics bool) (baseDir string, useGoMod bool) {
290
290
}
291
291
if len (goModPaths ) > 1 {
292
292
// currently not supported
293
+ baseDir = "."
294
+ commonRoot , nested := checkDirsNested (goModDirs )
295
+ if nested && commonRoot == "" {
296
+ useGoMod = true
297
+ } else {
298
+ useGoMod = false
299
+ }
293
300
if emitDiagnostics {
294
- if checkDirsNested ( goModDirs ) {
301
+ if nested {
295
302
diagnostics .EmitMultipleGoModFoundNested (goModPaths )
296
303
} else {
297
304
diagnostics .EmitMultipleGoModFoundNotNested (goModPaths )
298
305
}
299
306
}
300
- baseDir = "."
301
- useGoMod = false
302
307
return
303
308
}
304
309
if emitDiagnostics {
You can’t perform that action at this time.
0 commit comments