Skip to content

Commit 73d0b7e

Browse files
authored
Merge pull request #15492 from github/mbg/go/include-versions-in-newer-diagnostic
Go: Include versions in newer Go version needed diagnostic
2 parents 8972133 + 90eba71 commit 73d0b7e

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

go/extractor/cli/go-autobuilder/go-autobuilder.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -546,9 +546,12 @@ func installDependenciesAndBuild() {
546546
// This diagnostic is not required if the system Go version is 1.21 or greater, since the
547547
// Go tooling should install required Go versions as needed.
548548
if semver.Compare(getEnvGoSemVer(), "v1.21.0") < 0 && goVersionInfo.Found && semver.Compare("v"+goVersionInfo.Version, getEnvGoSemVer()) > 0 {
549-
diagnostics.EmitNewerGoVersionNeeded()
549+
diagnostics.EmitNewerGoVersionNeeded(getEnvGoSemVer(), "v"+goVersionInfo.Version)
550550
if val, _ := os.LookupEnv("GITHUB_ACTIONS"); val == "true" {
551-
log.Printf("The go.mod version is newer than the installed version of Go. Consider adding an actions/setup-go step to your workflow.\n")
551+
log.Printf(
552+
"The go.mod file requires version %s of Go, but version %s is installed. Consider adding an actions/setup-go step to your workflow.\n",
553+
"v"+goVersionInfo.Version,
554+
getEnvGoSemVer())
552555
}
553556
}
554557

go/extractor/diagnostics/diagnostics.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,11 @@ func EmitCannotFindPackages(pkgPaths []string) {
168168
)
169169
}
170170

171-
func EmitNewerGoVersionNeeded() {
171+
func EmitNewerGoVersionNeeded(installedVersion string, requiredVersion string) {
172172
emitDiagnostic(
173173
"go/autobuilder/newer-go-version-needed",
174174
"Newer Go version needed",
175-
"The detected version of Go is lower than the version specified in `go.mod`. [Install a newer version](https://github.com/actions/setup-go#basic).",
175+
"Version `"+installedVersion+"` of Go is installed, but this is lower than `"+requiredVersion+"` required by your project's `go.mod`. [Install a newer version of Go before analyzing your project](https://github.com/actions/setup-go#basic).",
176176
severityError,
177177
fullVisibility,
178178
noLocation,

0 commit comments

Comments
 (0)