Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Go extension for Visual Studio Code

License

NotificationsYou must be signed in to change notification settings

golang/vscode-go

Repository files navigation

Slack

The VS Code Go extensionprovides rich language support for theGo programming language.

Requirements

  • Visual Studio Code 1.90 or newer (or editors compatible with VS Code 1.90+ APIs)
  • Go 1.21 or newer.

Quick Start

Welcome! 👋🏻
Whether you are new to Go or an experienced Go developer, we hope thisextension fits your needs and enhances your development experience.

  1. InstallGo 1.21 or newer if you haven't already.

  2. Install theVS Code Go extension.

  3. 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.

  4. The extension depends ongo,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.


(Install Missing Tools)

You are ready to Go :-)    🎉🎉🎉

What's next

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.

Feature highlights

  • 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.


(Toggle Test File)

⚠️ Note: the default syntax highlighting for Go files is provided by aTextMate rule embedded in VSCode, not by this extension.

For better syntax highlighting, we recommend enablingsemantic highlightingby turning onGopls'ui.semanticTokens setting."gopls": { "ui.semanticTokens": true }

Setting up your workspace

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.

Pre-release version

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.patchfor 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.

Telemetry

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.

Support Policy

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.

Supported Go and tools

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.

Contributing

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.

Code of Conduct

This project follows theGo Community Code of Conduct. If you encounter aconduct-related issue, please mailconduct@golang.org.

License

MIT


[8]ページ先頭

©2009-2025 Movatter.jp