Skip to content

Commit ec044b1

Browse files
committed
gopls: update dependencies following the v0.10.0 release
Update selected dependencies following the v0.10.0 release, excluding sergi/go-diff and x/vuln. [email protected] requires go1.18, so link it selectively following the pattern of staticcheck. While at it, clean up some things related to the wiring of staticcheck and gofumpt support. Notably, in VS Code error messages do not support formatting such as newlines or tabs. Add a test for the conditional Gofumpt support. For golang/go#56211 Change-Id: Id09fdcc30ad83c0ace11b0dea9a5556a6461d552 Reviewed-on: https://go-review.googlesource.com/c/tools/+/446736 Run-TryBot: Robert Findley <[email protected]> Reviewed-by: Hyang-Ah Hana Kim <[email protected]> gopls-CI: kokoro <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
1 parent 2b29c66 commit ec044b1

12 files changed

+159
-104
lines changed

gopls/go.mod

+7-7
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,28 @@ module golang.org/x/tools/gopls
33
go 1.18
44

55
require (
6-
github.com/google/go-cmp v0.5.8
6+
github.com/google/go-cmp v0.5.9
77
github.com/jba/printsrc v0.2.2
88
github.com/jba/templatecheck v0.6.0
99
github.com/sergi/go-diff v1.1.0
1010
golang.org/x/mod v0.6.0
1111
golang.org/x/sync v0.1.0
1212
golang.org/x/sys v0.1.0
1313
golang.org/x/text v0.4.0
14-
golang.org/x/tools v0.1.13-0.20220928184430-f80e98464e27
14+
golang.org/x/tools v0.2.0
1515
golang.org/x/vuln v0.0.0-20221010193109-563322be2ea9
1616
gopkg.in/yaml.v3 v3.0.1
1717
honnef.co/go/tools v0.3.3
18-
mvdan.cc/gofumpt v0.3.1
18+
mvdan.cc/gofumpt v0.4.0
1919
mvdan.cc/xurls/v2 v2.4.0
2020
)
2121

22-
require golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e // indirect
22+
require golang.org/x/exp v0.0.0-20221031165847-c99f073a8326 // indirect
2323

2424
require (
25-
github.com/BurntSushi/toml v1.2.0 // indirect
26-
github.com/google/safehtml v0.0.2 // indirect
27-
golang.org/x/exp/typeparams v0.0.0-20220722155223-a9213eeb770e // indirect
25+
github.com/BurntSushi/toml v1.2.1 // indirect
26+
github.com/google/safehtml v0.1.0 // indirect
27+
golang.org/x/exp/typeparams v0.0.0-20221031165847-c99f073a8326 // indirect
2828
)
2929

3030
replace golang.org/x/tools => ../

gopls/go.sum

+18-13
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
22
github.com/BurntSushi/toml v0.4.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
3-
github.com/BurntSushi/toml v1.2.0 h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0=
4-
github.com/BurntSushi/toml v1.2.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
3+
github.com/BurntSushi/toml v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak=
4+
github.com/BurntSushi/toml v1.2.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
55
github.com/client9/misspell v0.3.4 h1:ta993UF76GwbvJcIo3Y68y/M3WxlpEHPWIGDkJYwzJI=
66
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
77
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
88
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
99
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
1010
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
11-
github.com/frankban/quicktest v1.14.2 h1:SPb1KFFmM+ybpEjPUhCCkZOM5xlovT5UbrMvWnXyBns=
12-
github.com/frankban/quicktest v1.14.2/go.mod h1:mgiwOwqx65TmIk1wJ6Q7wvnVMocbUorkibMOrVTHZps=
11+
github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE=
12+
github.com/frankban/quicktest v1.14.3/go.mod h1:mgiwOwqx65TmIk1wJ6Q7wvnVMocbUorkibMOrVTHZps=
1313
github.com/google/go-cmdtest v0.4.1-0.20220921163831-55ab3332a786/go.mod h1:apVn/GCasLZUVpAJ6oWAuyP7Ne7CEsQbTnc0plM3m+o=
1414
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
1515
github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE=
16-
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
1716
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
17+
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
18+
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
1819
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
19-
github.com/google/safehtml v0.0.2 h1:ZOt2VXg4x24bW0m2jtzAOkhoXV0iM8vNKc0paByCZqM=
2020
github.com/google/safehtml v0.0.2/go.mod h1:L4KWwDsUJdECRAEpZoBn3O64bQaywRscowZjJAzjHnU=
21+
github.com/google/safehtml v0.1.0 h1:EwLKo8qawTKfsi0orxcQAZzu07cICaBeFMegAU9eaT8=
22+
github.com/google/safehtml v0.1.0/go.mod h1:L4KWwDsUJdECRAEpZoBn3O64bQaywRscowZjJAzjHnU=
2123
github.com/jba/printsrc v0.2.2 h1:9OHK51UT+/iMAEBlQIIXW04qvKyF3/vvLuwW/hL8tDU=
2224
github.com/jba/printsrc v0.2.2/go.mod h1:1xULjw59sL0dPdWpDoVU06TIEO/Wnfv6AHRpiElTwYM=
2325
github.com/jba/templatecheck v0.6.0 h1:SwM8C4hlK/YNLsdcXStfnHWE2HKkuTVwy5FKQHt5ro8=
@@ -33,8 +35,9 @@ github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsK
3335
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
3436
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
3537
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
36-
github.com/rogpeppe/go-internal v1.8.1 h1:geMPLpDpQOgVyCg5z5GoRwLHepNdb71NXb67XFkP+Eg=
3738
github.com/rogpeppe/go-internal v1.8.1/go.mod h1:JeRgkft04UBgHMgCIwADu4Pn6Mtm5d4nPKWu0nJ5d+o=
39+
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
40+
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
3841
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
3942
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
4043
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
@@ -43,11 +46,12 @@ github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81P
4346
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
4447
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
4548
golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw=
46-
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e h1:+WEEuIdZHnUeJJmEUjyYC2gfUMj69yZXw17EnHg/otA=
4749
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e/go.mod h1:Kr81I6Kryrl9sr8s2FK3vxD90NdsKWRuOIl2O4CvYbA=
50+
golang.org/x/exp v0.0.0-20221031165847-c99f073a8326 h1:QfTh0HpN6hlw6D3vu8DAwC8pBIwikq0AI1evdm+FksE=
51+
golang.org/x/exp v0.0.0-20221031165847-c99f073a8326/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
4852
golang.org/x/exp/typeparams v0.0.0-20220218215828-6cf2b201936e/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk=
49-
golang.org/x/exp/typeparams v0.0.0-20220722155223-a9213eeb770e h1:7Xs2YCOpMlNqSQSmrrnhlzBXIE/bpMecZplbLePTJvE=
50-
golang.org/x/exp/typeparams v0.0.0-20220722155223-a9213eeb770e/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk=
53+
golang.org/x/exp/typeparams v0.0.0-20221031165847-c99f073a8326 h1:fl8k2zg28yA23264d82M4dp+YlJ3ngDcpuB1bewkQi4=
54+
golang.org/x/exp/typeparams v0.0.0-20221031165847-c99f073a8326/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk=
5155
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY=
5256
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
5357
golang.org/x/mod v0.6.0 h1:b9gGHsz9/HhJ3HF5DHQytPpuwocVTChQJK3AvoLRD5I=
@@ -56,14 +60,15 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v
5660
golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco=
5761
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
5862
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
63+
golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
5964
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
6065
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
6166
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
6267
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
6368
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
6469
golang.org/x/sys v0.0.0-20211213223007-03aa0b5f6827/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
65-
golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
6670
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
71+
golang.org/x/sys v0.0.0-20220829200755-d48e67d00261/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
6772
golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U=
6873
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
6974
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
@@ -89,8 +94,8 @@ gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
8994
honnef.co/go/tools v0.2.2/go.mod h1:lPVVZ2BS5TfnjLyizF7o7hv7j9/L+8cZY2hLyjP9cGY=
9095
honnef.co/go/tools v0.3.3 h1:oDx7VAwstgpYpb3wv0oxiZlxY+foCpRAwY7Vk6XpAgA=
9196
honnef.co/go/tools v0.3.3/go.mod h1:jzwdWgg7Jdq75wlfblQxO4neNaFFSvgc1tD5Wv8U0Yw=
92-
mvdan.cc/gofumpt v0.3.1 h1:avhhrOmv0IuvQVK7fvwV91oFSGAk5/6Po8GXTzICeu8=
93-
mvdan.cc/gofumpt v0.3.1/go.mod h1:w3ymliuxvzVx8DAutBnVyDqYb1Niy/yCJt/lk821YCE=
97+
mvdan.cc/gofumpt v0.4.0 h1:JVf4NN1mIpHogBj7ABpgOyZc65/UUOkKQFkoURsz4MM=
98+
mvdan.cc/gofumpt v0.4.0/go.mod h1:PljLOHDeZqgS8opHRKLzp2It2VBuSdteAgqUfzMTxlQ=
9499
mvdan.cc/unparam v0.0.0-20211214103731-d0ef000c54e5 h1:Jh3LAeMt1eGpxomyu3jVkmVZWW2MxZ1qIIV2TZ/nRio=
95100
mvdan.cc/unparam v0.0.0-20211214103731-d0ef000c54e5/go.mod h1:b8RRCBm0eeiWR8cfN88xeq2G5SG3VKGO+5UPWi5FSOY=
96101
mvdan.cc/xurls/v2 v2.4.0 h1:tzxjVAj+wSBmDcF6zBB7/myTy3gX9xvi8Tyr28AuQgc=

gopls/internal/hooks/analysis.go

-62
This file was deleted.

gopls/internal/hooks/analysis_116.go

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright 2021 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
//go:build !go1.17
6+
// +build !go1.17
7+
8+
package hooks
9+
10+
import "golang.org/x/tools/gopls/internal/lsp/source"
11+
12+
func updateAnalyzers(options *source.Options) {
13+
options.StaticcheckSupported = false
14+
}

gopls/internal/hooks/analysis_117.go

+53-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,62 @@
1-
// Copyright 2021 The Go Authors. All rights reserved.
1+
// Copyright 2019 The Go Authors. All rights reserved.
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
//go:build !go1.17
6-
// +build !go1.17
5+
//go:build go1.17
6+
// +build go1.17
77

88
package hooks
99

10-
import "golang.org/x/tools/gopls/internal/lsp/source"
10+
import (
11+
"golang.org/x/tools/gopls/internal/lsp/protocol"
12+
"golang.org/x/tools/gopls/internal/lsp/source"
13+
"honnef.co/go/tools/analysis/lint"
14+
"honnef.co/go/tools/quickfix"
15+
"honnef.co/go/tools/simple"
16+
"honnef.co/go/tools/staticcheck"
17+
"honnef.co/go/tools/stylecheck"
18+
)
1119

1220
func updateAnalyzers(options *source.Options) {
13-
options.StaticcheckSupported = false
21+
options.StaticcheckSupported = true
22+
23+
mapSeverity := func(severity lint.Severity) protocol.DiagnosticSeverity {
24+
switch severity {
25+
case lint.SeverityError:
26+
return protocol.SeverityError
27+
case lint.SeverityDeprecated:
28+
// TODO(dh): in LSP, deprecated is a tag, not a severity.
29+
// We'll want to support this once we enable SA5011.
30+
return protocol.SeverityWarning
31+
case lint.SeverityWarning:
32+
return protocol.SeverityWarning
33+
case lint.SeverityInfo:
34+
return protocol.SeverityInformation
35+
case lint.SeverityHint:
36+
return protocol.SeverityHint
37+
default:
38+
return protocol.SeverityWarning
39+
}
40+
}
41+
add := func(analyzers []*lint.Analyzer, skip map[string]struct{}) {
42+
for _, a := range analyzers {
43+
if _, ok := skip[a.Analyzer.Name]; ok {
44+
continue
45+
}
46+
47+
enabled := !a.Doc.NonDefault
48+
options.AddStaticcheckAnalyzer(a.Analyzer, enabled, mapSeverity(a.Doc.Severity))
49+
}
50+
}
51+
52+
add(simple.Analyzers, nil)
53+
add(staticcheck.Analyzers, map[string]struct{}{
54+
// This check conflicts with the vet printf check (golang/go#34494).
55+
"SA5009": {},
56+
// This check relies on facts from dependencies, which
57+
// we don't currently compute.
58+
"SA5011": {},
59+
})
60+
add(stylecheck.Analyzers, nil)
61+
add(quickfix.Analyzers, nil)
1462
}

gopls/internal/hooks/gofumpt_117.go

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2021 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
//go:build !go1.18
6+
// +build !go1.18
7+
8+
package hooks
9+
10+
import "golang.org/x/tools/gopls/internal/lsp/source"
11+
12+
func updateGofumpt(options *source.Options) {
13+
}

gopls/internal/hooks/gofumpt_118.go

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright 2022 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
//go:build go1.18
6+
// +build go1.18
7+
8+
package hooks
9+
10+
import (
11+
"context"
12+
13+
"golang.org/x/tools/gopls/internal/lsp/source"
14+
"mvdan.cc/gofumpt/format"
15+
)
16+
17+
func updateGofumpt(options *source.Options) {
18+
options.GofumptFormat = func(ctx context.Context, langVersion, modulePath string, src []byte) ([]byte, error) {
19+
return format.Source(src, format.Options{
20+
LangVersion: langVersion,
21+
ModulePath: modulePath,
22+
})
23+
}
24+
}

gopls/internal/hooks/hooks.go

+1-9
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,8 @@
88
package hooks // import "golang.org/x/tools/gopls/internal/hooks"
99

1010
import (
11-
"context"
12-
1311
"golang.org/x/tools/gopls/internal/lsp/source"
1412
"golang.org/x/tools/internal/diff"
15-
"mvdan.cc/gofumpt/format"
1613
"mvdan.cc/xurls/v2"
1714
)
1815

@@ -29,11 +26,6 @@ func Options(options *source.Options) {
2926
}
3027
}
3128
options.URLRegexp = xurls.Relaxed()
32-
options.GofumptFormat = func(ctx context.Context, langVersion, modulePath string, src []byte) ([]byte, error) {
33-
return format.Source(src, format.Options{
34-
LangVersion: langVersion,
35-
ModulePath: modulePath,
36-
})
37-
}
3829
updateAnalyzers(options)
30+
updateGofumpt(options)
3931
}

gopls/internal/hooks/licenses_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ import (
1515
)
1616

1717
func TestLicenses(t *testing.T) {
18-
// License text differs for older Go versions because staticcheck isn't
19-
// supported for those versions.
20-
testenv.NeedsGo1Point(t, 17)
18+
// License text differs for older Go versions because staticcheck or gofumpt
19+
// isn't supported for those versions.
20+
testenv.NeedsGo1Point(t, 18)
2121

2222
if runtime.GOOS != "linux" && runtime.GOOS != "darwin" {
2323
t.Skip("generating licenses only works on Unixes")

gopls/internal/lsp/source/options.go

+9-5
Original file line numberDiff line numberDiff line change
@@ -1036,10 +1036,8 @@ func (o *Options) set(name string, value interface{}, seen map[string]struct{})
10361036
if v, ok := result.asBool(); ok {
10371037
o.Staticcheck = v
10381038
if v && !o.StaticcheckSupported {
1039-
// Warn if the user is trying to enable staticcheck, but staticcheck is
1040-
// unsupported.
1041-
result.Error = fmt.Errorf("applying setting %q: staticcheck is not supported at %s\n"+
1042-
"\trebuild gopls with a more recent version of Go", result.Name, runtime.Version())
1039+
result.Error = fmt.Errorf("applying setting %q: staticcheck is not supported at %s;"+
1040+
" rebuild gopls with a more recent version of Go", result.Name, runtime.Version())
10431041
}
10441042
}
10451043

@@ -1059,7 +1057,13 @@ func (o *Options) set(name string, value interface{}, seen map[string]struct{})
10591057
result.setBool(&o.ShowBugReports)
10601058

10611059
case "gofumpt":
1062-
result.setBool(&o.Gofumpt)
1060+
if v, ok := result.asBool(); ok {
1061+
o.Gofumpt = v
1062+
if v && o.GofumptFormat == nil {
1063+
result.Error = fmt.Errorf("applying setting %q: gofumpt is not supported at %s;"+
1064+
" rebuild gopls with a more recent version of Go", result.Name, runtime.Version())
1065+
}
1066+
}
10631067

10641068
case "semanticTokens":
10651069
result.setBool(&o.SemanticTokens)

gopls/internal/regtest/misc/configuration_test.go

+15
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,21 @@ var FooErr = errors.New("foo")
8080
})
8181
}
8282

83+
func TestGofumptWarning(t *testing.T) {
84+
testenv.SkipAfterGo1Point(t, 17)
85+
86+
WithOptions(
87+
Settings{"gofumpt": true},
88+
).Run(t, "", func(t *testing.T, env *Env) {
89+
env.Await(
90+
OnceMet(
91+
InitialWorkspaceLoad,
92+
ShownMessage("gofumpt is not supported"),
93+
),
94+
)
95+
})
96+
}
97+
8398
func TestDeprecatedSettings(t *testing.T) {
8499
WithOptions(
85100
Settings{

0 commit comments

Comments
 (0)