Skip to content

Commit 375be68

Browse files
committed
Fix diagnostics
1 parent edebebf commit 375be68

File tree

2 files changed

+65
-32
lines changed

2 files changed

+65
-32
lines changed

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@ func getVersionWhenGoModVersionTooHigh(v versionInfo) (msg, version string) {
782782
") is above the supported range (" + minGoVersion + "-" + maxGoVersion +
783783
"). Writing an environment file not specifying any version of Go."
784784
version = ""
785-
diagnostics.EmitUnsupportedVersionGoMod(msg)
785+
diagnostics.EmitGoModVersionTooHigh(msg)
786786

787787
return msg, version
788788
}
@@ -799,7 +799,7 @@ func getVersionWhenGoModVersionTooLow(v versionInfo) (msg, version string) {
799799
"). No version of Go installed. Writing an environment file specifying the " +
800800
"minimum supported version of Go (" + minGoVersion + ")."
801801
version = minGoVersion
802-
diagnostics.EmitNoGoEnv(msg)
802+
diagnostics.EmitGoModVersionTooLowAndNoGoEnv(msg)
803803
} else if outsideSupportedRange(v.goEnvVersion) {
804804
// The version of Go that is installed is outside of the supported range. The version
805805
// in the `go.mod` file is below the supported range. Go versions are generally
@@ -811,15 +811,15 @@ func getVersionWhenGoModVersionTooLow(v versionInfo) (msg, version string) {
811811
"Writing an environment file specifying the minimum supported version of Go (" +
812812
minGoVersion + ")."
813813
version = minGoVersion
814-
diagnostics.EmitVersionGoModSupportedAndGoEnvUnsupported(msg)
814+
diagnostics.EmitGoModVersionTooLowAndEnvVersionUnsupported(msg)
815815
} else {
816816
// The version of Go that is installed is supported. The version in the `go.mod` file is
817817
// below the supported range. We do not install a version of Go.
818818
msg = "The version of Go installed in the environment (" + v.goEnvVersion +
819819
") is supported and is high enough for the version found in the `go.mod` file (" +
820820
v.goModVersion + "). Writing an environment file not specifying any version of Go."
821821
version = ""
822-
diagnostics.EmitVersionGoModNotHigherVersionEnvironment(msg)
822+
diagnostics.EmitGoModVersionTooLowAndEnvVersionSupported(msg)
823823
}
824824

825825
return msg, version
@@ -834,7 +834,7 @@ func getVersionWhenGoModVersionSupported(v versionInfo) (msg, version string) {
834834
msg = "No version of Go installed. Writing an environment file specifying the version " +
835835
"of Go found in the `go.mod` file (" + v.goModVersion + ")."
836836
version = v.goModVersion
837-
diagnostics.EmitNoGoEnv(msg)
837+
diagnostics.EmitGoModVersionSupportedAndNoGoEnv(msg)
838838
} else if outsideSupportedRange(v.goEnvVersion) {
839839
// The version of Go that is installed is outside of the supported range. The version in
840840
// the `go.mod` file is supported. We install the version from the `go.mod` file.
@@ -843,7 +843,7 @@ func getVersionWhenGoModVersionSupported(v versionInfo) (msg, version string) {
843843
"Writing an environment file specifying the version of Go from the `go.mod` file (" +
844844
v.goModVersion + ")."
845845
version = v.goModVersion
846-
diagnostics.EmitVersionGoModSupportedAndGoEnvUnsupported(msg)
846+
diagnostics.EmitGoModVersionSupportedAndGoEnvUnsupported(msg)
847847
} else if semver.Compare("v"+v.goModVersion, "v"+v.goEnvVersion) > 0 {
848848
// The version of Go that is installed is supported. The version in the `go.mod` file is
849849
// supported and is higher than the version that is installed. We install the version from
@@ -853,7 +853,7 @@ func getVersionWhenGoModVersionSupported(v versionInfo) (msg, version string) {
853853
"). Writing an environment file specifying the version of Go from the `go.mod` " +
854854
"file (" + v.goModVersion + ")."
855855
version = v.goModVersion
856-
diagnostics.EmitVersionGoModHigherVersionEnvironment(msg)
856+
diagnostics.EmitGoModVersionSupportedHigherGoEnv(msg)
857857
} else {
858858
// The version of Go that is installed is supported. The version in the `go.mod` file is
859859
// supported and is lower than or equal to the version that is installed. We do not install
@@ -862,7 +862,7 @@ func getVersionWhenGoModVersionSupported(v versionInfo) (msg, version string) {
862862
") is supported and is high enough for the version found in the `go.mod` file (" +
863863
v.goModVersion + "). Writing an environment file not specifying any version of Go."
864864
version = ""
865-
diagnostics.EmitVersionGoModNotHigherVersionEnvironment(msg)
865+
diagnostics.EmitGoModVersionSupportedLowerEqualGoEnv(msg)
866866
}
867867

868868
return msg, version

go/extractor/diagnostics/diagnostics.go

Lines changed: 57 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -194,87 +194,120 @@ func EmitRelativeImportPaths() {
194194
)
195195
}
196196

197-
func EmitUnsupportedVersionGoMod(msg string) {
197+
func EmitNoGoModAndNoGoEnv(msg string) {
198198
emitDiagnostic(
199-
"go/autobuilder/env-unsupported-version-in-go-mod",
200-
"Unsupported Go version in `go.mod` file",
199+
"go/autobuilder/env-no-go-mod-no-go-env",
200+
"No `go.mod` file found and no Go version in environment",
201201
msg,
202202
severityNote,
203203
telemetryOnly,
204204
noLocation,
205205
)
206206
}
207207

208-
func EmitNoGoModAndNoGoEnv(msg string) {
208+
func EmitNoGoModAndGoEnvUnsupported(msg string) {
209209
emitDiagnostic(
210-
"go/autobuilder/env-no-go-mod-and-no-go-env",
211-
"No `go.mod` file found and no Go version in environment",
210+
"go/autobuilder/env-no-go-mod-go-env-unsupported",
211+
"No `go.mod` file found and Go version in environment is unsupported",
212212
msg,
213213
severityNote,
214214
telemetryOnly,
215215
noLocation,
216216
)
217217
}
218218

219-
func EmitNoGoEnv(msg string) {
219+
func EmitNoGoModAndGoEnvSupported(msg string) {
220220
emitDiagnostic(
221-
"go/autobuilder/env-no-go-env",
222-
"No Go version in environment",
221+
"go/autobuilder/env-no-go-mod-go-env-supported",
222+
"No `go.mod` file found and Go version in environment is supported",
223223
msg,
224224
severityNote,
225225
telemetryOnly,
226226
noLocation,
227227
)
228228
}
229229

230-
func EmitNoGoModAndGoEnvUnsupported(msg string) {
230+
func EmitGoModVersionTooHigh(msg string) {
231231
emitDiagnostic(
232-
"go/autobuilder/env-no-go-mod-go-env-unsupported",
233-
"No `go.mod` file found and Go version in environment is unsupported",
232+
"go/autobuilder/env-go-mod-version-too-high",
233+
"Go version in `go.mod` file above supported range",
234234
msg,
235235
severityNote,
236236
telemetryOnly,
237237
noLocation,
238238
)
239239
}
240240

241-
func EmitNoGoModAndGoEnvSupported(msg string) {
241+
func EmitGoModVersionTooLowAndNoGoEnv(msg string) {
242242
emitDiagnostic(
243-
"go/autobuilder/env-no-go-mod-go-env-supported",
244-
"No `go.mod` file found and Go version in environment is supported",
243+
"go/autobuilder/env-go-mod-version-too-low-no-go-env",
244+
"Go version in `go.mod` file below supported range and no Go version in environment",
245+
msg,
246+
severityNote,
247+
telemetryOnly,
248+
noLocation,
249+
)
250+
}
251+
252+
func EmitGoModVersionTooLowAndEnvVersionUnsupported(msg string) {
253+
emitDiagnostic(
254+
"go/autobuilder/env-go-mod-version-too-low-go-env-unsupported",
255+
"Go version in `go.mod` file below supported range and Go version in environment unsupported",
256+
msg,
257+
severityNote,
258+
telemetryOnly,
259+
noLocation,
260+
)
261+
}
262+
263+
func EmitGoModVersionTooLowAndEnvVersionSupported(msg string) {
264+
emitDiagnostic(
265+
"go/autobuilder/env-go-mod-version-too-low-go-env-supported",
266+
"Go version in `go.mod` file below supported range and Go version in environment supported",
267+
msg,
268+
severityNote,
269+
telemetryOnly,
270+
noLocation,
271+
)
272+
}
273+
274+
func EmitGoModVersionSupportedAndNoGoEnv(msg string) {
275+
emitDiagnostic(
276+
"go/autobuilder/env-go-mod-version-supported-no-go-env",
277+
"Go version in `go.mod` file in supported range and no Go version in environment",
245278
msg,
246279
severityNote,
247280
telemetryOnly,
248281
noLocation,
249282
)
250283
}
251284

252-
func EmitVersionGoModHigherVersionEnvironment(msg string) {
285+
func EmitGoModVersionSupportedAndGoEnvUnsupported(msg string) {
253286
emitDiagnostic(
254-
"go/autobuilder/env-version-go-mod-higher-than-go-env",
255-
"The Go version in `go.mod` file is higher than the Go version in environment",
287+
"go/autobuilder/env-go-mod-version-supported-go-env-unsupported",
288+
"Go version in `go.mod` file in supported range and Go version in environment unsupported",
256289
msg,
257290
severityNote,
258291
telemetryOnly,
259292
noLocation,
260293
)
261294
}
262295

263-
func EmitVersionGoModSupportedAndGoEnvUnsupported(msg string) {
296+
func EmitGoModVersionSupportedHigherGoEnv(msg string) {
264297
emitDiagnostic(
265-
"go/autobuilder/env-version-go-mod-higher-than-go-env",
266-
"The Go version in `go.mod` file is higher than the Go version in environment",
298+
"go/autobuilder/env-go-mod-version-supported-higher-than-go-env",
299+
"The Go version in `go.mod` file is supported and higher than the Go version in environment",
267300
msg,
268301
severityNote,
269302
telemetryOnly,
270303
noLocation,
271304
)
272305
}
273306

274-
func EmitVersionGoModNotHigherVersionEnvironment(msg string) {
307+
func EmitGoModVersionSupportedLowerEqualGoEnv(msg string) {
275308
emitDiagnostic(
276-
"go/autobuilder/env-version-go-mod-lower-than-or-equal-to-go-env",
277-
"The Go version in `go.mod` file is lower than or equal to the Go version in environment",
309+
"go/autobuilder/env-go-mod-version-supported-lower-than-or-equal-to-go-env",
310+
"The Go version in `go.mod` file is supported and lower than or equal to the Go version in environment",
278311
msg,
279312
severityNote,
280313
telemetryOnly,

0 commit comments

Comments
 (0)