2

After upgrade every time I open VS Code I get a Error loading workspace folders and Even All the extension were not working

go [-e -json -compiled=true -test=true -export=false -deps=true -find=false -- builtin ibm.com/cloudbroker/order/...]: exit status 1: build flag -mod=readonly only valid when using modules
: packages.Load error[![enter image description here][1]][1]

go version go1.12.17 darwin/amd64 VsCode Version: 1.52.1 OS: Darwin x64 20.2.0

Image Error Messgae

enter image description here

Anupam Somani
  • 224
  • 1
  • 7
  • 17

4 Answers4

9

January 28 marked a major milestone in both the gopls and VS Code Go journeys, as gopls is now enabled by default in the Go extension for VS Code.

https://blog.golang.org/gopls-vscode-go

you need to disable the go.useLanguageServer flag in your settings.json

mine looks like this:

{
    "go.inferGopath": false,
    "go.toolsGopath": "C:\\Go",
    "go.useLanguageServer": false
}
chondroboy
  • 156
  • 2
  • 1
    Error loading workspace folders has been resolved but still I am getting error extension prettier Code formatter cannot format – Anupam Somani Feb 04 '21 at 17:53
  • this problem has been answered here. https://stackoverflow.com/questions/52586965/why-prettier-does-not-format-code-in-vscode – chondroboy Feb 13 '21 at 12:29
1

I have been struggling with this same issue for a while, thankfully after reading VScode workspace thread and gopals thread, my problem has resolved

My Go Project Structure

Project Structure

In VS code, open working project Repository alone.

Inside the project, run

go mod init module_name

go mod tidy

Hope, this helps

Yuvaraj
  • 491
  • 6
  • 6
0

I am using Windows and I had the same error and for me it was due to a mismatch between the path as it is on the disk vs the path on my powershell session from where I invoked vscode. Windows is not case sensitive when it comes to file paths but when I naviguate to my go project using powershell, I have to respect the case sensitivity for it to work.

Hope, this helps.

Noteworthy
  • 349
  • 4
  • 5
0

The full error I was getting was that the System32 was showing as system32. On the Terminal, just changed the path.

cd ..  
cd System32
S.B
  • 13,077
  • 10
  • 22
  • 49
Chris
  • 1
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jun 07 '22 at 06:21