Skip to content

Commit 3e17c62

Browse files
committed
internal/lsp: warn users who have built gopls with go-diff v1.2.0
I considered having gopls not initialize at all, but VS Code Go intercepts those error messages and they get buried. We should probably fix that in VS Code Go, but for now just show a warning. Updates golang/go#45732 Change-Id: I214974e5a96231c96b1583af8ac245de03cea5d8 Reviewed-on: https://go-review.googlesource.com/c/tools/+/315852 Trust: Rebecca Stambler <[email protected]> Run-TryBot: Rebecca Stambler <[email protected]> Reviewed-by: Robert Findley <[email protected]> gopls-CI: kokoro <[email protected]> TryBot-Result: Go Bot <[email protected]>
1 parent def0263 commit 3e17c62

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

internal/lsp/general.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,24 @@ func (s *Server) initialize(ctx context.Context, params *protocol.ParamInitializ
9696
}
9797
}
9898

99-
goplsVersion, err := json.Marshal(debug.VersionInfo())
99+
versionInfo := debug.VersionInfo()
100+
101+
// golang/go#45732: Warn users who've installed sergi/[email protected], since
102+
// it will corrupt the formatting of their files.
103+
for _, dep := range versionInfo.Deps {
104+
if dep.Path == "github.com/sergi/go-diff" && dep.Version == "v1.2.0" {
105+
if err := s.eventuallyShowMessage(ctx, &protocol.ShowMessageParams{
106+
Message: `It looks like you have a bad gopls installation.
107+
Please reinstall gopls by running 'GO111MODULE=on go get golang.org/x/tools/gopls@latest'.
108+
See https://github.com/golang/go/issues/45732 for more information.`,
109+
Type: protocol.Error,
110+
}); err != nil {
111+
return nil, err
112+
}
113+
}
114+
}
115+
116+
goplsVersion, err := json.Marshal(versionInfo)
100117
if err != nil {
101118
return nil, err
102119
}

0 commit comments

Comments
 (0)