Skip to content

Commit

Permalink
Go: Emit relative path import diagnostic if prompted by go mod tidy
Browse files Browse the repository at this point in the history
The corresponding integration test now successfully extracts the project
  • Loading branch information
mbg committed Jan 24, 2024
1 parent cd35b6f commit 45c349a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion go/extractor/cli/go-autobuilder/go-autobuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -463,8 +463,15 @@ func initGoModForLegacyProject(buildInfo project.BuildInfo) {
modTidy := exec.Command("go", "mod", "tidy")
modTidy.Dir = buildInfo.BaseDir

if !util.RunCmd(modTidy) {
out, err := modTidy.CombinedOutput()
log.Println(out)

if err != nil {
log.Printf("Failed to determine module requirements for this project.")

if strings.Contains(string(out), "is relative, but relative import paths are not supported in module mode") {
diagnostics.EmitRelativeImportPaths()
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
goPath = os.path.join(os.path.abspath(os.getcwd()), ".go")
os.environ['GOPATH'] = goPath
os.environ['GITHUB_REPOSITORY'] = "a/b"
run_codeql_database_create([], lang="go", source="work", db=None, runFunction=runUnsuccessfully)
run_codeql_database_create([], lang="go", source="work", db=None)

check_diagnostics()

Expand Down

0 comments on commit 45c349a

Please sign in to comment.