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: empty title for go mod tidy suggested fix #43234

Closed
zhaytee opened this issue Dec 17, 2020 · 8 comments
Closed

x/tools/gopls: empty title for go mod tidy suggested fix #43234

zhaytee opened this issue Dec 17, 2020 · 8 comments

Comments

@zhaytee
Copy link

@zhaytee zhaytee commented Dec 17, 2020

What version of Go, VS Code & VS Code Go extension are you using?

go version: go1.14.9 linux/amd64
gopls version: golang.org/x/tools/gopls v0.6.0
vscode version: 1.52.1 (commit ea3859d4ba2f3e577a159bc91e3074c5d85c0523)
vscode-go version: 0.19.1

Checking configured tools....
GOBIN: undefined
toolsGopath: 
gopath: /home/zhaytee/go
GOROOT: /usr/local/go
PATH: /usr/local/go/bin:/home/zhaytee/.vscode-server/bin/ea3859d4ba2f3e577a159bc91e3074c5d85c0523/bin:/home/zhaytee/.nvm/versions/node/v12.18.4/bin:/home/zhaytee/.vscode-server/bin/ea3859d4ba2f3e577a159bc91e3074c5d85c0523/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/zhaytee/go/bin:/home/zhaytee/.local/bin

   gocode: gocode not installed
   gopkgs: gopkgs not installed
   go-outline: go-outline not installed
   go-symbols: go-symbols not installed
   guru: guru not installed
   gorename: gorename not installed
   gotests: gotests not installed
   gomodifytags: gomodifytags not installed
   impl: impl not installed
   fillstruct: fillstruct not installed
   goplay: goplay not installed
   godoctor: godoctor not installed
   dlv: dlv not installed
   gocode-gomod: gocode-gomod not installed
   godef: godef not installed
   goreturns: goreturns not installed
   golint: golint not installed
   gopls: /home/zhaytee/go/bin/gopls installed

go env
Workspace Folder (api): /home/zhaytee/Development/platform/api
	GO111MODULE=""
	GOARCH="amd64"
	GOBIN=""
	GOCACHE="/home/zhaytee/.cache/go-build"
	GOENV="/home/zhaytee/.config/go/env"
	GOEXE=""
	GOFLAGS=""
	GOHOSTARCH="amd64"
	GOHOSTOS="linux"
	GOINSECURE=""
	GONOPROXY=""
	GONOSUMDB=""
	GOOS="linux"
	GOPATH="/home/zhaytee/go"
	GOPRIVATE=""
	GOPROXY="https://proxy.golang.org,direct"
	GOROOT="/usr/local/go"
	GOSUMDB="sum.golang.org"
	GOTMPDIR=""
	GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
	GCCGO="gccgo"
	AR="ar"
	CC="gcc"
	CXX="g++"
	CGO_ENABLED="1"
	GOMOD=""
	CGO_CFLAGS="-g -O2"
	CGO_CPPFLAGS=""
	CGO_CXXFLAGS="-g -O2"
	CGO_FFLAGS="-g -O2"
	CGO_LDFLAGS="-g -O2"
	PKG_CONFIG="pkg-config"
	GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build361984029=/tmp/go-build -gno-record-gcc-switches"

Share the Go related settings you have added/edited

{
    "go.autocompleteUnimportedPackages": true,
    "gopls": {
        "usePlaceholders": false,
        "staticcheck": false
    },
    "go.languageServerExperimentalFeatures": {
        "diagnostics": true
    },
    "[go.mod]": {
        "editor.formatOnSave": true,
        "editor.codeActionsOnSave": {
            "source.organizeImports": true,
        },
    },
    "[go]": {
        "editor.formatOnSave": true,
        "editor.codeActionsOnSave": {
            "source.organizeImports": true,
        },
        "editor.snippetSuggestions": "none",
    }
}

Describe the bug

VSCode is running on macOS, vscode-go is running on linux/amd64 (I'm using the remote-ssh extension).

I just upgraded to gopls 0.60. Now vscode is yelling at me about the workspace needing go.mod changes, presumably due to the -mod=readonly change introduced to gopls 0.60. The status bar reads "Error loading workspace", and has a permanent spinner.

I'm not aware of anything I can do configuration-wise to solve this problem, so I think this might count as a bug. Not entirely sure.

Error loading workspace: go [-e -json -compiled=true -test=true -export=false -deps=true -find=false -- builtin github.com/myorg/platform/api/compiled/go/...]: exit status 1: go: updates to go.mod needed, disabled by -mod=readonly

Any help would be appreciated. Thank you.

@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Dec 17, 2020

Do you see any diagnostics on the files in your workspace, likely on a go.mod file? You can check by opening the Problems pane via the Command Palette (Ctrl+Shift+P -> Problems: Focus on Problems View). If there is a diagnostic, it will have an associated suggested fix which you can apply.

@zhaytee
Copy link
Author

@zhaytee zhaytee commented Dec 17, 2020

Hi @stamblerre

Yes, looks like there is a diag line in there. The fix seems a bit busted though, it's two empty entries. I'm a little wary of clicking on them. 😅

Screen Shot 2020-12-16 at 5 57 06 PM

I guess I could run "go mod tidy" manually. It seems a little unfortunate though, from a workflow perspective. Is this expected to be the normal workflow for vscode-go going forward with gopls >= 0.60?

Thank you!

@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Dec 17, 2020

The fix seems a bit busted though, it's two empty entries. I'm a little wary of clicking on them. 😅

I'm not sure I understand this--what empty entries are you referring to? All that fix will do is run go mod tidy in your module, which is the same as running it on the command line.

And yes, the go command is defaulting to -mod=readonly which means that, in the future, any go build or go test command will break until your module is tidied. gopls is just adopting this behavior a little bit early--before Go 1.16.

@zhaytee
Copy link
Author

@zhaytee zhaytee commented Dec 17, 2020

@stamblerre Notice the menu dropdown. I'm assuming there are two fixes listed there, but they are both blank, i.e. they don't describe what they do, their name, or anything. So I'm being asked to click on a menu item which is blank. I suspect there's supposed to be some text there.

@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Dec 17, 2020

Oh I didn't realize that was a drop-down menu. Thank you for pointing that out--I will transfer this to the gopls issue tracker and make sure we get a fix in for that.

@stamblerre stamblerre transferred this issue from golang/vscode-go Dec 17, 2020
@stamblerre stamblerre changed the title "Error loading workspace" after upgrading gopls to 0.60 x/tools/gopls: empty title for go mod tidy suggested fix Dec 17, 2020
@gopherbot gopherbot added this to the Unreleased milestone Dec 17, 2020
@zhaytee
Copy link
Author

@zhaytee zhaytee commented Dec 17, 2020

Sounds good. Thanks for letting me know about the expected workflow going forward!

@zhaytee zhaytee closed this Dec 17, 2020
@zhaytee zhaytee reopened this Dec 17, 2020
@stamblerre stamblerre modified the milestones: Unreleased, gopls/v0.6.1 Dec 17, 2020
@gopherbot
Copy link

@gopherbot gopherbot commented Dec 17, 2020

Change https://golang.org/cl/278778 mentions this issue: internal/lsp: add titles to go mod tidy and update go.sum fixes

@gopherbot
Copy link

@gopherbot gopherbot commented Dec 17, 2020

Change https://golang.org/cl/278785 mentions this issue: [gopls-release-branch.0.6] internal/lsp: add titles to go mod tidy and update go.sum fixes

gopherbot pushed a commit to golang/tools that referenced this issue Dec 17, 2020
…and update go.sum fixes

These were missing titles, which was showing up empty for users in the
VS Code UI and leading people not to trust the fixes.

Also did a find references on SuggestedFix to confirm that we always
set the title in other cases.

Fixes golang/go#43234

Change-Id: I8d0f272c383a2e1a364aefcec6650988d18d4fb4
Reviewed-on: https://go-review.googlesource.com/c/tools/+/278778
Trust: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
(cherry picked from commit 48e5bd1)
Reviewed-on: https://go-review.googlesource.com/c/tools/+/278785
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Dec 20, 2020
0.6.1

This is a patch release to fix golang/go#43234. The titles of some
suggested fixes were blank, leading to a bad user experience.

0.6.0

Features
- Default to -mod=readonly
- Default to GOPROXY=off
- Inclusion/exclusion filters for directories
- Debouncing for diagnostics
- "Upgrade direct dependencies" code lens
- Support for filling a partially-populated struct
- Experimental: Field alignment analyzer

Fixes
- Improvements to diagnostics tracking
- File watching for directories

Other
- "codelens" setting name changed to "codelenses"
- Disabled support for symlinks
marwan-at-work added a commit to marwan-at-work/tools that referenced this issue Dec 23, 2020
These were missing titles, which was showing up empty for users in the
VS Code UI and leading people not to trust the fixes.

Also did a find references on SuggestedFix to confirm that we always
set the title in other cases.

Fixes golang/go#43234

Change-Id: I8d0f272c383a2e1a364aefcec6650988d18d4fb4
Reviewed-on: https://go-review.googlesource.com/c/tools/+/278778
Trust: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants