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 {
249249 return dirs
250250}
251251
252- func checkDirsNested (inputDirs []string ) bool {
252+ func checkDirsNested (inputDirs []string ) ( string , bool ) {
253253 // replace "." with "" so that we can check if all the paths are nested
254254 dirs := make ([]string , len (inputDirs ))
255255 for i , inputDir := range inputDirs {
@@ -264,10 +264,10 @@ func checkDirsNested(inputDirs []string) bool {
264264 sort .Strings (dirs )
265265 for _ , dir := range dirs {
266266 if ! strings .HasPrefix (dir , dirs [0 ]) {
267- return false
267+ return "" , false
268268 }
269269 }
270- return true
270+ return dirs [ 0 ], true
271271}
272272
273273// 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) {
290290 }
291291 if len (goModPaths ) > 1 {
292292 // currently not supported
293+ baseDir = "."
294+ commonRoot , nested := checkDirsNested (goModDirs )
295+ if nested && commonRoot == "" {
296+ useGoMod = true
297+ } else {
298+ useGoMod = false
299+ }
293300 if emitDiagnostics {
294- if checkDirsNested ( goModDirs ) {
301+ if nested {
295302 diagnostics .EmitMultipleGoModFoundNested (goModPaths )
296303 } else {
297304 diagnostics .EmitMultipleGoModFoundNotNested (goModPaths )
298305 }
299306 }
300- baseDir = "."
301- useGoMod = false
302307 return
303308 }
304309 if emitDiagnostics {
You can’t perform that action at this time.
0 commit comments