Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/tools/gopls: address formatting issues with go-diff@v1.2.0 #45732

Closed
findleyr opened this issue Apr 23, 2021 · 7 comments
Closed

x/tools/gopls: address formatting issues with go-diff@v1.2.0 #45732

findleyr opened this issue Apr 23, 2021 · 7 comments
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.

Comments

@findleyr
Copy link
Contributor

In #45648, we discovered that gopls has formatting bugs when built with github.com/sergi/go-diff@v1.2.0. Unfortunately, there are probably many users that get this version due to installing with go get -u.

Until sergi/go-diff#115 is fixed, or we find some other solution, we should at least warn users when built with go-diff@v1.2.0.

CC @stamblerre @heschi

@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Apr 23, 2021
@gopherbot gopherbot added this to the Unreleased milestone Apr 23, 2021
@findleyr findleyr modified the milestones: Unreleased, gopls/v0.6.11 Apr 23, 2021
@suzmue suzmue changed the title x/tools/gopls: guard against formatting issues with go-diff@v1.2.0 x/tools/gopls: address formatting issues with go-diff@v1.2.0 Apr 30, 2021
@stamblerre stamblerre self-assigned this Apr 30, 2021
@gopherbot
Copy link

Change https://golang.org/cl/315852 mentions this issue: internal/lsp: warn users who have built gopls with go-diff v1.2.0

gopherbot pushed a commit to golang/tools that referenced this issue May 3, 2021
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 <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
@stamblerre stamblerre modified the milestones: gopls/v0.7.0, gopls/v0.7.1 Jun 4, 2021
@stamblerre stamblerre modified the milestone: gopls/v0.7.1 Jun 23, 2021
@stamblerre
Copy link
Contributor

I don't think there's anything to do here. All that remains is waiting for sergi/go-diff#120 to be merged.

@stamblerre stamblerre removed this from the gopls/v0.7.1 milestone Jun 25, 2021
@FrankFang
Copy link

What's the correct way to install x/tools/gopls?

@findleyr
Copy link
Contributor Author

See https://github.com/golang/tools/tree/master/gopls#installation

GO111MODULE=on go get golang.org/x/tools/gopls@latest

@OscarVanL
Copy link

OscarVanL commented Oct 1, 2021

The VS Code Go Extension has started complaining about a bad gopls installation, linking to this issue.

I tried running the command suggested by VS Code to fix it (same as above) but it says:

go get: installing executables with 'go get' in module mode is deprecated.
        Use 'go install pkg@version' instead.
        For more information, see https://golang.org/doc/go-get-install-deprecation
        or run 'go help get' or 'go help install'.

If I run go install golang.org/x/tools/gopls@latestI get no console output whatsoever and the error message does not go away.

Any idea what to do? Lots of stuff seems to be misbehaving. When I have the "go.useLanguageServer": true,option set VS Code will give incorrect errors on every third-party import, such as:

"gopkg.in/yaml.v3" imported but not usedcompilerUnusedImport
could not import gopkg.in/yaml.v3 (cannot find package "gopkg.in/yaml.v3" in any of 
	/usr/local/Cellar/go/1.17.1/libexec/src/gopkg.in/yaml.v3 (from $GOROOT)
	/Users/oscarvanleusen/go/src/gopkg.in/yaml.v3 (from $GOPATH))

However, this library must be installed as the code compiles fine (and yaml functions work). If I disable the language server the warning goes away.

Here's my settings.json file.

{
    "workbench.colorTheme": "Default Dark+",
    "files.autoSave": "afterDelay",
    "go.useLanguageServer": true,
    "go.languageServerExperimentalFeatures": {
            "diagnostics": true // for diagnostics as you type
    },
    "[go]": {
        "editor.insertSpaces": false,
        "editor.formatOnSave": true,
        "editor.codeActionsOnSave": {
            "source.organizeImports": true
        },
        "editor.suggest.snippetsPreventQuickSuggestions": false
    },
    
    "go.liveErrors": {
        "enabled": true,
        "delay": 500
    },
    "go.lintTool": "revive",
    "go.toolsManagement.autoUpdate": true,
    "telemetry.enableTelemetry": false,
    "telemetry.enableCrashReporter": false,
    "gopls": {

        "usePlaceholders": true, // add parameter placeholders when completing a function
    },
}

I've tried uninstalling Go and reinstalling it from scratch and this has not solved the problem.

I've spent ages trying to get Go to work properly on my Mac with VS Code, but am close to giving up and trying Goland. Any suggestions?

@stamblerre
Copy link
Contributor

@OscarVanL: Please take a look at the Troubleshooting guide and open a new issue if that doesn't help you solve the problem.

@IzhakJakov
Copy link

Why does he needs to open a new issue??
This is a problem with the plugin suggesting to do something that does not work anymore and refers me to this issue for more information.
If he opens a new issue, then, the plugin should refer me to that new issue instead of this one.

@golang golang locked and limited conversation to collaborators Jun 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

6 participants