-
Notifications
You must be signed in to change notification settings - Fork 0
Go modules support in Visual Studio Code
This wiki page tracks the status of Go modules support in the Go extension for Visual Studio Code
As you already know, the Go extension depends on various Go tools from the community to provide language support. Some of these tools support Go modules already, and others don't. Therefore, you will see that some features of the Go extension will work and others won't.
https://github.com/golang/go/issues/24661 is the issue used by the Go tools team to track the update of Go modules support in various Go tools.
To get Go module support in VS Code, ensure that you have the latest Go extension and you have run Go: Install/Update Tools
to update all the relevant tools. If you are missing any of the tools, you will get prompted to install them.
- Run
Go: Install/Update Tools
, selectgocode-gomod
andgodef-gomod
, press Ok to get the latest updates for these tools which improve the auto-completion and code navigation features. - Run
go get github.com/saibing/bingo
and add the below in your settings if you want to make use of the language server bingo by @saibing
"go.alternateTools": {
"go-langserver": "bingo",
},
"go.languageServerExperimentalFeatures": {
"format": true,
"autoComplete": true
},
"go.useLanguageServer": true
Apart from what we have already achieved in v0.6.90, the below are available in the current beta version
- Code Coverage
- Clickable links in the test output to files where tests are failing.
-
Go to definition, symbol info on hover and Signature Help
- These features will work as expected when the setting
go.docsTool
is set togogetdoc
. - You will be prompted to update
gogetdoc
- These features will work as expected when the setting
-
Go to definition feature
- If you havent changed the
go.docsTool
setting, you will be prompted to install a fork ofgodef
that we are testing. -
Note: This feature may be slower than usual because the fork depends on
go list
which itself is slower when using modules.
- If you havent changed the
-
Auto-completion.
- You will be prompted to install a fork of
gocode
that we are testing as well as to update thegopkgs
tool. - Currently it only works if the package is already imported and used atleast once.
-
Note: This feature may be slower than usual because the fork depends on
go list
which itself is slower when using modules.
- You will be prompted to install a fork of
-
Go: Add Import
&Go: Browse Packages
commands- These commands will show the appropriate packages from the current module instead of GOPATH
-
Formatting
-
goimports
andgoreturns
do not support Go modules yet. So, to get the formatting feature, add"go.formatTool": "gofmt"
in your settings.
-
To ensure you have the latest Go tools with the Go modules support, and follow the prompts to install/update the required tools.
-
Build : The build on save features as well as the
Go: Build ...
commands -
Test : Running tests via the
Go: Test
commands as well as the "run tests" codelens. -
Generating of tests using the
Go: Generate ...
commands - File Outline: Either via the Outline view in the explorer or using the command Cmd+Shift+O or Ctrl+Shift+O
-
Modify tags on struct fields:
Go: Add tags to struct fields
&Go: Remove tags from struct fields
commands - Code snippets
- Debugging
These are tracked as issues and have the label go-modules