- Notifications
You must be signed in to change notification settings - Fork811
Go extension for Visual Studio Code
License
golang/vscode-go
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
The VS Code Go extensionprovides rich language support for theGo programming language.
- Visual Studio Code 1.90 or newer (or editors compatible with VS Code 1.90+ APIs)
- Go 1.21 or newer.
Welcome! 👋🏻
Whether you are new to Go or an experienced Go developer, we hope thisextension fits your needs and enhances your development experience.
InstallGo 1.21 or newer if you haven't already.
Install theVS Code Go extension.
Open any Go file or go.mod file to automatically activate the extension. TheGo status bar appears in thebottom right corner of the window and displays your Go version.
The extension depends on
go
,gopls
(the Go language server), and optionaltools depending on your settings. Ifgopls
is missing, the extension willtry to install it. The ⚡ sign next to the Go version indicatesthe language server is running, and you are ready to go.
You are ready to Go :-) 🎉🎉🎉
- Explore morefeatures of the VS Code Go extension.
- View thesettings documentationandadvanced topics tocustomize the extension.
- View thetools documentationfor a complete list of tools the VS Code Go extension depends on. You caninstall additional tools and update them by using "Go: Install/Update Tools".
- Solve issues with thegeneral troubleshootinganddebugging troubleshootingguides.
- file an issue forproblems with the extension.
- Start aGitHub discussionor get help onStack Overflow.
- Explore Go language resources ongo.dev/learn andgolang.org/help.
If you are new to Go,this article providesthe overview on Go code organization and basicgo
commands. Watch"Gettingstarted with VS Code Go" for an explanation of how to build your first Goapplication using VS Code Go.
- IntelliSense - Results appear for symbols as you type.
- Code navigation - Jump to or peek at a symbol's declaration.
- Code editing - Support for saved snippets, formatting and code organization,and automatic organization of imports.
- Diagnostics - Build, vet, and lint errors shown as you type or on save.
- Enhanced support fortesting anddebugging
See thefull feature breakdown for more details.
(Code completion and Signature Help)
In addition to integrated editing features, the extension provides severalcommands for working with Go files. You can access any of these by opening theCommand Palette (Ctrl+Shift+P
on Linux/Windows andCmd+Shift+P
on Mac), andthen typing in the command name. See thefull list of commands provided by thisextension.
For better syntax highlighting, we recommend enablingsemantic highlightingby turning onGopls'ui.semanticTokens
setting."gopls": { "ui.semanticTokens": true }
The VS Code Go extension supports bothGOPATH
and Go modules modes.
Go modules are used to manage dependencies inrecent versions of Go. Modules replace theGOPATH
-based approach to specifyingwhich source files are used in a given build, and they are the default buildmode in go1.16+. We highly recommend Go development in module mode. If you areworking on existing projects, please consider migrating to modules.
Unlike the traditionalGOPATH
mode, module mode does not require the workspaceto be located underGOPATH
nor to use a specific structure. A module isdefined by a directory tree of Go source files with ago.mod
file in thetree's root directory.
Your project may involve one or more modules. If you are working with multiplemodules or uncommon project layouts, you will need to configure your workspaceby usingWorkspace Folders. See theSupported workspace layouts documentation for more information.
If you'd like to get early access to new features and bug fixes, you can use thepre-release extension. Following the vscode'sconvention,we use the minor version of the extension version number to distinguish stableand pre-release versions (0.ODD_NUMBER.patch
for pre-release,0.EVEN_NUMBER.patch
for stable release).
To install the pre-release version, use the drop-down listto select "Install Pre-Release Version", or if already installed the Go extension,use the "Switch to Pre-Release Version" option in the Visual Studio Codeextension management page. For more details about this mechanism, see theVisual Studio Code's documentation.
VS Code Go extension relies on theGo Telemetry tolearn insights about the performance and stability of the extension and thelanguage server (gopls
).Go Telemetry data uploading is disabled by default and can be enabledwith the following command:
go run golang.org/x/telemetry/cmd/gotelemetry@latest on
After telemetry is enabled, the language server will upload metrics and stacktraces totelemetry.go.dev. You can inspect whatdata is collected and can be uploaded by running:
go run golang.org/x/telemetry/cmd/gotelemetry@latest view
If we get enough adoption, this data can significantly advance the pace ofthe Go extension development, and help us meet a higher standardof reliability. For example:
- Even withsemi-automated crashreportsin VS Code, we've seen several crashers go unreported for weeks or months.
- Even witha suite ofbenchmarks,some performance regressions don't show up in our benchmark environment (suchas thecompletion bug mentioned below!).
- Even withlots of greatideasfor how to improve gopls, we have limited resources. Telemetry can help usidentify which new features are most important, and which existing featuresaren't being used or aren't working well.
These are just a few ways that telemetry can improve gopls. Thetelemetry blogpost series contains many more.
Go telemetry is designed to be transparent and privacy-preserving. Learn more athttps://go.dev/doc/telemetry.
The Go extension is maintained by engineers on theGo tools team,who actively monitor theVS Code Goand theGoissue trackers.
We support only the latest stable and pre-release versions of the extension.
The Go extension follows theGo Release Policy,meaning that itofficially supports the two most recent major Go releases.The Go team maintainsbest-effort support for the last three major Go versions.
The Go extension relies ontoolslikegopls
anddlv
for its core functionalities and they have their own releasepolicy and schedule. We test only against the latest versions of these tools.
In case you need to work with an older version of Go, please checktheCompatibility page and manually install the compatible version ofthe extension and tools.
We welcome your contributions and thank you for working to improve the Godevelopment experience in VS Code. If you would like to help work on the VS CodeGo extension, see ourcontribution guide tolearn how to build and run the VS Code Go extension locally and contribute tothe project.
This project follows theGo Community Code of Conduct. If you encounter aconduct-related issue, please mailconduct@golang.org.
About
Go extension for Visual Studio Code
Topics
Resources
License
Code of conduct
Security policy
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Uh oh!
There was an error while loading.Please reload this page.