Skip to content

Commit 8bd7553

Browse files
findleyrgopherbot
authored andcommitted
gopls/internal/util/goversion: warn about EOL for Go 1.18
Gopls v0.15.0 will be the final gopls version to support Go 1.18, so include a warning, as is our practice. Fixes golang/go#64407 Change-Id: I215631420c05ad1922312f1b1009d15577ddb01e Reviewed-on: https://go-review.googlesource.com/c/tools/+/549115 Reviewed-by: Alan Donovan <[email protected]> Auto-Submit: Robert Findley <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent bc9cd15 commit 8bd7553

File tree

2 files changed

+52
-12
lines changed

2 files changed

+52
-12
lines changed

gopls/internal/util/goversion/goversion.go

+17-5
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,17 @@ import (
1414
//
1515
// Exposed for testing.
1616
type Support struct {
17-
GoVersion int
18-
DeprecatedVersion string // if unset, the version is already deprecated
17+
// GoVersion is the Go version to which these settings relate.
18+
GoVersion int
19+
20+
// DeprecatedVersion is the first version of gopls that no longer supports
21+
// this Go version.
22+
//
23+
// If unset, the version is already deprecated.
24+
DeprecatedVersion string
25+
26+
// InstallGoplsVersion is the latest gopls version that supports this Go
27+
// version without warnings.
1928
InstallGoplsVersion string
2029
}
2130

@@ -29,12 +38,15 @@ type Support struct {
2938
var Supported = []Support{
3039
{12, "", "v0.7.5"},
3140
{15, "", "v0.9.5"},
32-
{16, "v0.13.0", "v0.11.0"},
33-
{17, "v0.13.0", "v0.11.0"},
41+
{16, "", "v0.11.0"},
42+
{17, "", "v0.11.0"},
43+
{18, "v0.16.0", "v0.14.2"},
3444
}
3545

3646
// OldestSupported is the last X in Go 1.X that this version of gopls
37-
// supports.
47+
// supports without warnings.
48+
//
49+
// Exported for testing.
3850
func OldestSupported() int {
3951
return Supported[len(Supported)-1].GoVersion + 1
4052
}

gopls/internal/util/goversion/goversion_test.go

+35-7
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,55 @@
55
package goversion_test
66

77
import (
8+
"fmt"
89
"strings"
910
"testing"
1011

1112
"golang.org/x/tools/gopls/internal/util/goversion"
1213
)
1314

1415
func TestMessage(t *testing.T) {
16+
// Note(rfindley): this test is a change detector, as it must be updated
17+
// whenever we deprecate a version.
18+
//
19+
// However, I chose to leave it as is since it gives us confidence in error
20+
// messages served for Go versions that we no longer support (and therefore
21+
// no longer run in CI).
22+
type test struct {
23+
goVersion int
24+
fromBuild bool
25+
wantContains []string // string fragments that we expect to see
26+
wantIsError bool // an error, not a mere warning
27+
}
28+
29+
deprecated := func(goVersion int, lastVersion string) test {
30+
return test{
31+
goVersion: goVersion,
32+
fromBuild: false,
33+
wantContains: []string{
34+
fmt.Sprintf("Found Go version 1.%d", goVersion),
35+
"not supported",
36+
fmt.Sprintf("upgrade to Go 1.%d", goversion.OldestSupported()),
37+
fmt.Sprintf("install gopls %s", lastVersion),
38+
},
39+
wantIsError: true,
40+
}
41+
}
42+
1543
tests := []struct {
1644
goVersion int
1745
fromBuild bool
1846
wantContains []string // string fragments that we expect to see
1947
wantIsError bool // an error, not a mere warning
2048
}{
2149
{-1, false, nil, false},
22-
{12, false, []string{"1.12", "not supported", "upgrade to Go 1.18", "install gopls v0.7.5"}, true},
23-
{13, false, []string{"1.13", "not supported", "upgrade to Go 1.18", "install gopls v0.9.5"}, true},
24-
{15, false, []string{"1.15", "not supported", "upgrade to Go 1.18", "install gopls v0.9.5"}, true},
25-
{15, true, []string{"Gopls was built with Go version 1.15", "not supported", "upgrade to Go 1.18", "install gopls v0.9.5"}, true},
26-
{16, false, []string{"1.16", "will be unsupported by gopls v0.13.0", "upgrade to Go 1.18", "install gopls v0.11.0"}, false},
27-
{17, false, []string{"1.17", "will be unsupported by gopls v0.13.0", "upgrade to Go 1.18", "install gopls v0.11.0"}, false},
28-
{17, true, []string{"Gopls was built with Go version 1.17", "will be unsupported by gopls v0.13.0", "upgrade to Go 1.18", "install gopls v0.11.0"}, false},
50+
deprecated(12, "v0.7.5"),
51+
deprecated(13, "v0.9.5"),
52+
deprecated(15, "v0.9.5"),
53+
deprecated(16, "v0.11.0"),
54+
deprecated(17, "v0.11.0"),
55+
{18, false, []string{"Found Go version 1.18", "unsupported by gopls v0.16.0", "upgrade to Go 1.19", "install gopls v0.14.2"}, false},
56+
{18, true, []string{"Gopls was built with Go version 1.18", "unsupported by gopls v0.16.0", "upgrade to Go 1.19", "install gopls v0.14.2"}, false},
2957
}
3058

3159
for _, test := range tests {

0 commit comments

Comments
 (0)