Skip to content

Commit 2a41e6a

Browse files
committed
Emit diagnostic to pass third inegration tests
1 parent 4fe4dfb commit 2a41e6a

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

go/extractor/diagnostics/diagnostics.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,16 @@ func EmitPackageDifferentOSArchitecture(pkgPath string) {
102102
)
103103
}
104104

105+
func EmitCannotFindPackage(pkgPath string) {
106+
emitDiagnostic("go/extractor/package-not-found",
107+
"Package "+pkgPath+" could not be found",
108+
"Check that the path is correct. If it is a private package, make sure it can be accessed. If it is contained in the repository then you may need a [custom build command](https://docs.github.com/en/github-ae@latest/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-the-codeql-workflow-for-compiled-languages#adding-build-steps-for-a-compiled-language)",
109+
severityError, false,
110+
true, true, true,
111+
"", 0, 0, 0, 0,
112+
)
113+
}
114+
105115
func EmitNewerGoVersionNeeded() {
106116
emitDiagnostic("go/autobuilder/newer-go-version-needed",
107117
"Newer Go version needed",

go/extractor/extractor.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,10 @@ func ExtractWithFlags(buildFlags []string, patterns []string) error {
151151
if strings.Contains(errString, "build constraints exclude all Go files in ") {
152152
// `err` is a NoGoError from the package cmd/go/internal/load, which we cannot access as it is internal
153153
diagnostics.EmitPackageDifferentOSArchitecture(pkg.PkgPath)
154+
} else if strings.Contains(errString, "cannot find package") ||
155+
strings.Contains(errString, "no required module provides package") {
156+
diagnostics.EmitCannotFindPackage(pkg.PkgPath)
154157
}
155-
156158
extraction.extractError(tw, err, lbl, i)
157159
}
158160
}

0 commit comments

Comments
 (0)