Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

> Set-Variable GO111MODULE -Value on
> go get golang.org/x/tools/gopls@latest
go: cannot use path@version syntax in GOPATH mode

So far I'm having a thoroughly horrible experience learning Go. It all started when I tried renaming a variable in VS Code. Here's the story.

  • I'm learning Go and have written about 10 lines, ever.
  • I'm on Windows :-[ which is proving a hurdle.
  • I'm running version 1.13 and I want to start as if Go Modules is all I've ever known.
  • I have neither a GOPATH or GOROOT environment variable set.
  • Go tooling seems to be in c:Go.
  • I downloaded the code for a book I'm reading and opened it in VS Code.
  • I have C:DATAgogopl.ioch1fetchallmain.go open in VS Code, c:DATAgo is where I stick my code.
  • VS Code has auto installed a bunch of Go tools to help me.
  • I tried to F2 rename a variable in func main to something that made more sense to me.
  • I encountered
Rename failed: gorename: can't find package containing (path to your .go file)

The solution to this error, as far as my noob brain understands is that I need to update a package called packages or perhaps gopls which is the Language Server used by VS Code or something.

So I ran c:DATA> go get golang.org/x/tools/gopls@latest but got an error that seemed to be something to do with new support for the syntax to specifying versions and Go Modules being new or something.

I then read for hours more and found that this has something to do with some GO111MODULE variable and what folder I run go get from.

Hence I tried setting that variable but it doesn't seem to work.

Note I'm running these commands from c:DATA rather than from where the book sample main.go code is, because I'm guessing that this Language Server package is not for that code, but is a thing that VS Code uses, and so its supposed to be "globally" installed somehow, somewhere? But I could be wrong.

As you can see, I haven't faintest idea what I'm doing and well, tbh, its not exactly fun :(

UPDATE

I do have a GOPATH set to c:DATAgo but in the VS Code terminal which is PowerShell, when I run Get-Variable its not listed, but if I then run cmd to enter a normal shell prompt, it is set. Strange.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
540 views
Welcome To Ask or Share your Answers For Others

1 Answer

Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...