@@ -282,6 +282,35 @@ func getBuildRoots(emitDiagnostics bool) (goWorkspaces []GoWorkspace, totalModul
282
282
283
283
// If there are no `go.mod` files at all, create one in line with https://go.dev/blog/migrating-to-go-modules
284
284
if totalModuleFiles == 0 {
285
+ // Check for other, legacy package managers
286
+ if util .FileExists ("Gopkg.toml" ) {
287
+ if emitDiagnostics {
288
+ diagnostics .EmitGopkgTomlFound ()
289
+ }
290
+ log .Println ("Found Gopkg.toml, using dep instead of go get" )
291
+ goWorkspaces = []GoWorkspace {{
292
+ BaseDir : "." ,
293
+ DepMode : Dep ,
294
+ ModMode : ModUnset ,
295
+ }}
296
+ totalModuleFiles = 0
297
+ return
298
+ }
299
+
300
+ if util .FileExists ("glide.yaml" ) {
301
+ if emitDiagnostics {
302
+ diagnostics .EmitGlideYamlFound ()
303
+ }
304
+ log .Println ("Found glide.yaml, using Glide instead of go get" )
305
+ goWorkspaces = []GoWorkspace {{
306
+ BaseDir : "." ,
307
+ DepMode : Glide ,
308
+ ModMode : ModUnset ,
309
+ }}
310
+ totalModuleFiles = 0
311
+ return
312
+ }
313
+
285
314
// If we have no `go.mod` files, then the project appears to be a legacy project without
286
315
// a `go.mod` file. Check that there are actually Go source files before initializing a module
287
316
// so that we correctly fail the extraction later.
@@ -372,34 +401,8 @@ func GetWorkspaceInfo(emitDiagnostics bool) []GoWorkspace {
372
401
}
373
402
374
403
goWorkspaces , totalModuleFiles := getBuildRoots (emitDiagnostics )
375
- if totalModuleFiles > 0 {
376
- log .Printf ("Found %d go.mod file(s): enabling go modules.\n " , totalModuleFiles )
377
- return goWorkspaces
378
- }
379
-
380
- if util .FileExists ("Gopkg.toml" ) {
381
- if emitDiagnostics {
382
- diagnostics .EmitGopkgTomlFound ()
383
- }
384
- log .Println ("Found Gopkg.toml, using dep instead of go get" )
385
- return []GoWorkspace {{
386
- BaseDir : "." ,
387
- DepMode : Dep ,
388
- ModMode : ModUnset ,
389
- }}
390
- }
404
+ log .Printf ("Found %d go.mod file(s).\n " , totalModuleFiles )
391
405
392
- if util .FileExists ("glide.yaml" ) {
393
- if emitDiagnostics {
394
- diagnostics .EmitGlideYamlFound ()
395
- }
396
- log .Println ("Found glide.yaml, using Glide instead of go get" )
397
- return []GoWorkspace {{
398
- BaseDir : "." ,
399
- DepMode : Glide ,
400
- ModMode : ModUnset ,
401
- }}
402
- }
403
406
return goWorkspaces
404
407
}
405
408
0 commit comments