Home > Enterprise >  corrupting golang file when saving in visual studio code
corrupting golang file when saving in visual studio code

Time:11-14

When I save a golang file in visual studio code, it ends up being corrupted -- characters are removed, not in any pattern I have discerned. This has occurred at various times in the past, but has just now recurred. For details, see my bug report, "corrupting file when saving in visual studio code #49465"1.

In the meantime, what I can do until it's fixed? Perhaps I could return to an older version of gopls, but I don't know how to do that.

Any suggestions welcome. I'm stuck until I can successfully save and run my go programs. Thanks!

CodePudding user response:

Please try running the following command

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

or

GO111MODULE=on go get golang.org/x/tools/gopls@v0.3.2-pre1

CodePudding user response:

In order to make progress on my project, I've downloaded the prior version of go from [https://golang.org/dl/]. At least on Windows, the downgrade installs like any upgrade, including offering to remove the existing version.

And I backed up gopls to its previous version using the facilities of VS Code: ctrl-shift-X to access extensions, right-click on Go, select Install Another Version... wait...wait...wait... and when the list of versions finally appears, select the one you want. I went back a month.

So, the underlying problem still exists, but I'm back in business. I hope these instructions can help someone else battling with the disappearing character bug.

  • Related