VScode show me the error after I install the proxy in vscode

21,608

Solution 1

You probably have more than one go module in your workspace. If that is the case, you can change the go extension settings, in order to allow gopls to look for multiple modules in the workspace. Just add the following to your settings.json:

"gopls": {
    "experimentalWorkspaceModule": true,
}

You can read more about gopls configuration in the docs: https://github.com/golang/tools/blob/master/gopls/doc/settings.md

Solution 2

To solve this, follow below steps :

step 1 : Open Vscode, and then go to settings.

step 2 : In the search bar , type gopls

step 3 : Just below that you will find settings.json, click on that

step 4 : Paste the below code their "gopls": { "experimentalWorkspaceModule": true, }

step 5 : Save it and restart the Vscode, You are good to go now.

Solution 3

I had this error because I had not created my modules inside a src directory. So I had:

$GOPATH
   -> bin
   -> pkg
   -> github.com
      -> Module
         -> go.mod

and that needed to be:

$GOPATH
   -> bin
   -> pkg
   -> src
       -> github.com
          -> Module
            -> go.mod
Share:
21,608
Admin
Author by

Admin

Updated on July 25, 2022

Comments

  • Admin
    Admin almost 2 years

    gopls requires a module at the root of your workspace. You can work with multiple modules by opening each one as a workspace folder. Improvements to this workflow will be coming soon (https://github.com/golang/go/issues/32394), and you can learn more here: https://github.com/golang/go/issues/36899.

  • Spencer Hire
    Spencer Hire over 2 years
    This is a good answer, especially for new learners setting up multiple workspaces while learning, different chapters for a book etc.
  • Arun
    Arun over 2 years
    This works perfectly.