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: bad edits for go.mod #39041

Closed
stamblerre opened this issue May 13, 2020 · 2 comments
Closed

x/tools/gopls: bad edits for go.mod #39041

stamblerre opened this issue May 13, 2020 · 2 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.
Milestone

Comments

@stamblerre
Copy link
Contributor

Repro case:

-- mod/go.mod --
module mod.com

go 1.14

require google.golang.org/protobuf v1.20.0
-- mod/main.go --
package main

import (
    "github.com/esimov/caire"
)

func _() {
    caire.RemoveTempImage()
}

There should be a diagnostic warning that "github.com/esimov/caire" is not in the go.mod file. Accepting the associated suggested fix will result in a go.mod file that looks like:

module mod.com

go 1.14

require (
	""
	github.com/esimov/caire v1.2.5
)
@stamblerre stamblerre added this to the gopls/v0.5.0 milestone May 13, 2020
@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 May 13, 2020
@tsaarni
Copy link
Contributor

tsaarni commented Jul 8, 2020

I got bitten by this problem with vscode + gopls.

Functions like "go to definition" in vscode were not working, and gopls server log was full of errors like (some details removed):

[Error - 9:48:32 AM] 2020/07/08 09:48:32 go/packages.Load: err: exit status 1: stderr: go: errors parsing go.mod:
/tmp/go.6d622aad12b2764936d0fec3aac1810fbc9fe4ff.794542754.mod:8: usage: require module/path v1.2.3
[Error - 9:48:32 AM] 2020/07/08 09:48:32 DocumentSymbols failed: getting file for DocumentSymbols: err: exit status 1: stderr: go: errors parsing go.mod:
/tmp/go.6d622aad12b2764936d0fec3aac1810fbc9fe4ff.794542754.mod:8: usage: require module/path v1.2.3
[Error - 9:48:32 AM] Request textDocument/codeAction failed.
[Error - 9:48:32 AM] 2020/07/08 09:48:32 go/packages.Load: err: exit status 1: stderr: go: errors parsing go.mod:
/tmp/go.6d622aad12b2764936d0fec3aac1810fbc9fe4ff.191457828.mod:8: usage: require module/path v1.2.3
[Error - 9:48:32 AM] 2020/07/08 09:48:32 failed to compute document links: err: exit status 1: stderr: go: errors parsing go.mod:
/tmp/go.6d622aad12b2764936d0fec3aac1810fbc9fe4ff.191457828.mod:8: usage: require module/path v1.2.3
[Error - 9:48:32 AM] Request textDocument/codeAction failed.
  Message: err: exit status 1: stderr: go: errors parsing go.mod:
/tmp/go.6d622aad12b2764936d0fec3aac1810fbc9fe4ff.439956726.mod:8: usage: require module/path v1.2.3
[Error - 9:48:32 AM] 2020/07/08 09:48:32 go/packages.Load: err: exit status 1: stderr: go: errors parsing go.mod:
/tmp/go.6d622aad12b2764936d0fec3aac1810fbc9fe4ff.439956726.mod:8: usage: require module/path v1.2.3
[Error - 9:48:32 AM] 2020/07/08 09:48:32 go/packages.Load: go [-e -json -compiled=true -test=true -export=false -deps=true -find=false -modfile=/tmp/go.6d622aad12b2764936d0fec3aac1810fbc9fe4ff.396872600.mod -- github.com/tsaarni/certyaml github.com/tsaarni/certyaml/pkg/certificate]: exit status 1: go: errors parsing go.mod:
/tmp/go.6d622aad12b2764936d0fec3aac1810fbc9fe4ff.396872600.mod:8: usage: require module/path v1.2.3
...

What made it particularly hard to debug was that the version of go.mod in filesystem was OK, so command line builds worked.
Only when I figured out to open the go.mod version within in vscode workspace I could see the empty line "" which was causing the problem:

module github.com/tsaarni/certyaml

go 1.13

require (
	github.com/cnf/structhash v0.0.0-20180104161610-62a607eb0224
	github.com/tsaarni/x500dn v0.0.0-20200116210152-667db92cf7b9
	""
	gopkg.in/yaml.v2 v2.3.0
	gopkg.in/yaml.v3 v3.0.0-20191120175047-4206685974f2
)

@gopherbot
Copy link

Change https://golang.org/cl/241443 mentions this issue: internal/lsp: add a repro case and fix for golang/go#39041

@stamblerre stamblerre modified the milestones: gopls/v0.5.0, gopls/v0.4.4 Jul 12, 2020
@golang golang locked and limited conversation to collaborators Jul 12, 2021
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

3 participants