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: doesn't recognize => token in go.mod #46246
Comments
replace
directive =>
tokens unsupported by gopls go.mod parser.
Gopls supports =>, and in fact has a replace in its own modfile. Also, per my reading of the error the unexpected token is "v0.13.0". That error is present in the go command, related to retraction, though not at 1.15.11. It's also present in x/mod (again for the Is it possible you typed 'retract' instead of 'replace'? Is it possible you have multiple versions of Go installed on your computer? Thanks. |
I pasted it here exactly as it appears in go.mod, namely
So it's definitely If it is supported as you claim, then I suppose it might somehow be related to the invalid go.mod state of the repo in question, but the errors thrown by |
The error indicates the local go.mod, and the go.mod in github.com/apache/thrift/lib/go/thrift at that version is empty. Gopls uses the same modfile parser as the go command: golang.org/x/mod. The error you see is either originating from executions of the go command, or from calls to x/mod from gopls. When I looked for it, it appears that its only occurrence is related to module retraction (linked above). Something strange is going on. Just as a sanity check, I did create a minimal module that uses that exact replace directive. Everything works fine.
So I suspect there is something else in your |
This was my argument for not dismissing this off-hand. I'll provide the full go.mod when I get back to work tomorrow. The ultimate cause is possibly due to this being a massive monorepo using please.build for a build system, which ultimately does all it's individual builds in GOPATH mode. Despite that, as far as I'm aware, gopls should be pulling in the go.mod and initializing based off that. Perhaps that assumption is my failing... I tried to be sure there weren't any queries being sent to the gopls server yet though, so the error occurs during initialization. If my assumptions there are false, then our repo itself could be at fault. |
Hi, I'm closing this as unactionable for now. Please re-open if you are able to gather more details. Thanks. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
Output ($HOME path redacted to~
. Proprietary workspace path redacted to[redacted]
)What did you do?
Added a
replace
directive to main workspacego.mod
file.replace github.com/apache/thrift v0.13.0 => github.com/apache/thrift/lib/go/thrift v0.0.0-20210120171102-e27e82c46ba4
What did you expect to see?
gopls
handling this properly.What did you see instead?
gopls
doesn't parse thego.mod
file correctly. It doesn't recognize=>
as valid tokens despite Go Modules specification clearly outlining the usage and grammar for the replace directive. https://golang.org/ref/mod#go-mod-file-replaceThe text was updated successfully, but these errors were encountered: