Skip to content

Commit c717b8d

Browse files
committed
[release] all: merge master to release for v0.22.0
063b57d src/goLanguageServer.ts: remove prompt when the default is changed 30b8fdb package.json: enable gopls by default b386aef src/goMain: show welcome page for 0.22.0 8d7dda0 src/goMain: adjust showGoWelcomePage to show for prereleases d993742 docs/settings: include enum and enum descriptions f534354 README.md: rewrite assuming gopls is on by default f99b5fb docs/features.md: add call hierarchy documentation 867b590 src/goTools: update hardcoded gopls latest version bb6665d docs/features.md: remove default tool description for gopls features 61305d9 src/welcome: re-work the welcome page 0a4362f CHANGELOG.md: v0.21.1 changelog fbd2fc4 src/goLanguageServer: partial revert of cl/280601 7f56895 src/util.ts: handle inactive languageClient bc20520 docs: rewrite troubleshooting guide f0680f9 docs: remove modules.md because it is not relevant with gopls enabled bcd1314 docs/features.md: add feature gifs for snippets and fill struct a267fff src/config: fix initConfig and WrappedConfiguration 2163a5a test/integration: increase installation test timeout 5011235 docs/features.md: Add gifs and images for features 4af88f9 docs/images: add gifs and images for features Change-Id: Ifbf8d58690409b40922d14dd318391b468b756f1
2 parents ea221fb + 063b57d commit c717b8d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1019
-1091
lines changed

README.md

Lines changed: 63 additions & 77 deletions
Large diffs are not rendered by default.

docs/commands.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Commands
22

3-
In addition to integrated editing features, this extension offers a number of commands, which can be executed manually through the [Command Palette](https://code.visualstudio.com/docs/getstarted/userinterface#_command-palette) (Ctrl+Shift+P).
3+
In addition to integrated editing features, this extension offers a number of commands, which can be executed manually through the [Command Palette](https://code.visualstudio.com/docs/getstarted/userinterface#_command-palette) (Ctrl+Shift+P on Linux/Windows or Cmd+Shift+P on Mac OS).
44

55
Some of these commands are also available in the VS Code context menu (right-click). To control which of these commands show up in the editor context menu, update the [`"go.editorContextMenuCommands"`](settings.md#go.editorContextMenuCommands) setting.
66

docs/debugging.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ logOutput | Comma-separated list of Delve components (`debugger`, `gdbwire`, `l
112112
buildFlags | Build flags to pass to the Go compiler. This corresponds to `dlv`'s `--build-flags` flag.
113113
dlvFlags | Extra flags passed to `dlv`. See `dlv help` for the full list of supported flags. This is useful when users need to pass less commonly used or new flags such as `--only-same-user`, `--check-go-version`. Note that some flags such as `--log-output`, `--log`, `--init`, `--api-version` already have corresponding properties in the debug configuration, and flags such as `--listen` and `--headless` are used internally. If they are specified in `dlvFlags`, they may be ignored or cause an error.
114114
remotePath | If remote debugging (`mode`: `remote`), this should be the absolute path to the package being debugged on the remote machine. See the section on [Remote Debugging](#remote-debugging) for further details. [golang/vscode-go#45](https://github.com/golang/vscode-go/issues/45) is also relevant. Becomes the first mapping in substitutePath.
115-
substitutePath | An array of mappings from an absolute local path to an absolute remote path that is used by the debuggee. The debug adapter will replace the local path with the remote path in all of the calls. The mappings are applied in order, and the first matching mapping is used. This can be used to map files that have moved since the program was built, different remote paths, and symlinked files or directories. This is intended to be equivalent to the [substitute-path]((https://github.com/go-delve/delve/tree/master/Documentation/cli#config)(https://github.com/go-delve/delve/tree/master/Documentation/cli#config)) configuration, and will eventually configure substitute-path in Delve directly.
115+
substitutePath | An array of mappings from an absolute local path to an absolute remote path that is used by the debuggee. The debug adapter will replace the local path with the remote path in all of the calls. The mappings are applied in order, and the first matching mapping is used. This can be used to map files that have moved since the program was built, different remote paths, and symlinked files or directories. This is intended to be equivalent to the [substitute-path](https://github.com/go-delve/delve/tree/master/Documentation/cli#config) configuration, and will eventually configure substitute-path in Delve directly.
116116
cwd | The working directory to be used in running the program. If remote debugging (`mode`: `remote`), this should be the absolute path to the working directory being debugged on the local machine. See the section on [Remote Debugging](#remote-debugging) for further details. [golang/vscode-go#45](https://github.com/golang/vscode-go/issues/45) is also relevant.
117117
processId | This is the process ID of the executable you want to debug. Applicable only when using the `attach` request in `local` mode.
118118

docs/features.md

Lines changed: 51 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22

33
This document describes the features supported by this extension.
44

5-
If you are using the Go language server, `gopls`, please the [gopls documentation](gopls.md) instead. (You can check if you are using `gopls` by opening your VS Code settings and checking if [`"go.useLanguageServer"`](settings.md#go.useLanguageServer) is `true`.)
6-
7-
If you are using Go modules **without** the language server, some of the features listed below will not be available.
8-
95
## Table of Contents
106

117
* [IntelliSense](#intellisense)
@@ -46,97 +42,132 @@ If you are using Go modules **without** the language server, some of the feature
4642

4743
### Code completion
4844

49-
Completion results appear for symbols as you type. You can trigger this manually with the Ctrl+Space shortcut. This feature is provided by the [`gocode`](tools.md#gocode) tool.
45+
Completion results appear for symbols as you type. You can trigger this manually with the Ctrl+Space shortcut.
5046

51-
Autocompletion is also supported for packages you have not yet imported into your program. This feature is provided by the [`gopkgs`](tools.md#gopkgs) tool.
47+
Autocompletion is also supported for packages you have not yet imported into your program.
5248

53-
### Signature help
49+
<div style="text-align: center;"><img src="images/completion-signature-help.gif" alt="Code completion and signature help" style="width: 75%"> </div>
5450

55-
Information about the signature of a function pops up as you type in its parameters. This feature is provided by the [`gogetdoc`](tools.md#documentation) tool, but it can also be provided by a combination of [`godef`](tools.md#documentation) and [`godoc`](tools.md#documentation) (configured via the [`"go.docsTool"`](settings.md#go.docsTool) setting).
51+
### Signature help
5652

53+
Information about the signature of a function pops up as you type in its parameters.
5754
### Quick info on hover
5855

59-
Documentation appears when you hover over a symbol. This feature is provided by the [`gogetdoc`](tools.md#documentation) tool, but it can also be provided by a combination of [`godef`](tools.md#documentation) and [`godoc`](tools.md#documentation) (configured via the [`"go.docsTool"`](settings.md#go.docsTool) setting).
56+
Documentation appears when you hover over a symbol.
6057

6158
## [Code Navigation](https://code.visualstudio.com/docs/editor/editingevolved)
6259

6360
### Go to definition
6461

65-
Jump to or peek a symbol's declaration. This feature is provided by the [`gogetdoc`](tools.md#documentation) tool, but it can also be provided by a combination of [`godef`](tools.md#documentation) and [`godoc`](tools.md#documentation) (configured via the [`"go.docsTool"`](settings.md#go.docsTool) setting).
62+
Jump to or peek a symbol's declaration.
63+
64+
<div style="text-align: center;"><img src="images/gotodefinition.gif" alt="Go to definition using the context menu" style="width: 75%"> </div>
6665

6766
### Find references
6867

69-
Find or go to the references of a symbol. This feature is provided the [`guru`](tools.md#guru) tool.
68+
Find or go to the references of a symbol.
7069

7170
This feature is not available if you are using Go modules **without** [`gopls`](gopls.md), the Go language server.
7271

72+
<div style="text-align: center;"><img src="images/findallreferences.gif" alt="Find references using the context menu" style="width: 75%"> </div>
73+
7374
### Find interface implementations
7475

75-
Find the concrete types that implement a given interface. This feature is provided by the [`guru`](tools.md#guru) tool.
76+
Find the concrete types that implement a given interface.
7677

7778
This feature is not available if you are using Go modules **without** [`gopls`](gopls.md), the Go language server.
7879

80+
<div style="text-align: center;"><img src="images/implementations.gif" alt="Go to implementations for Server that implements http.Handler and then finds all implementations of http.Handler in the workspace" style="width: 75%"> </div>
81+
7982
### [Go to symbol](https://code.visualstudio.com/docs/editor/editingevolved#_go-to-symbol)
8083

8184
Search for symbols in your file or workspace by opening the Command Palette (Ctrl+Shift+P) and typing `@` for symbols in the current file or `#` for symbols in the entire workspace.
8285

83-
This feature is provided by the [`go-outline`](tools.md#go-outline) and [`go-symbols`](tools.md#go-symbols) tools.
86+
<div style="text-align: center;"><img src="images/workspace-symbols.gif" alt="Use Workspace Symbols to locate Hello in the workspace" style="width: 75%"> </div>
87+
88+
### Call hierarchy
89+
90+
Show all calls from or to a function.
91+
92+
<div style="text-align: center;"><img src="images/callhierarchy.gif" alt="Show call hierarchy and investigate callers of a function" style="width: 75%"> </div>
8493

8594
### Document outline
8695

8796
See all the symbols in the current file in the VS Code's [Outline view](https://code.visualstudio.com/docs/getstarted/userinterface#_outline-view).
8897

89-
This feature is provided by the [`go-outline`](tools.md#go-outline) tool.
98+
<div style="text-align: center;"><img src="images/outline.png" alt="Outline of a Go file" style="width: 75%"> </div>
9099

91100
### Toggle between code and tests
92101

93102
Quickly toggle between a file and its corresponding test file by using the [`Go: Toggle Test File`](commands.md#go-toggle-test-file) command.
94103

104+
<div style="text-align: center;"><img src="images/toggletestfile.gif" alt="Toggle between reverse.go and reverse_test.go" style="width: 75%"> </div>
105+
95106
## Code Editing
96107

97108
### [Snippets](https://code.visualstudio.com/docs/editor/userdefinedsnippets)
98109

99110
Predefined snippets for quick coding. These snippets will appear as completion suggestions when you type. Users can also define their own custom snippets (see [Snippets in Visual Studio Code](https://code.visualstudio.com/docs/editor/userdefinedsnippets#_create-your-own-snippets)).
100111

112+
<div style="text-align: center;"><img src="images/snippets-tys.gif" alt="Use the struct type snippet" style="width: 75%"> </div>
113+
101114
### Format and organize imports
102115

103-
Format code and organize imports, either manually or on save. The code is formatted by the [`gofmt`](tools.md#formatting) tool, which is the standard for Go code. Imports are added automatically to your file via the [`goimports`](tools.md#formatting) tool, which is also an industry standard. By default, this extension also uses the [`goreturns`](tools.md#formatting) tool, which automatically fills in default return values for functions.
116+
Format code and organize imports, either manually or on save.
104117

105-
The behavior of the formatter can be configured via the [`"go.formatTool"`](settings.md#go.formatTool) tool setting. The [troubleshooting guide](troubleshooting.md#formatting) gives more details and explains how to [disable formatting](troubleshooting.md#disable-formatting) entirely.
118+
The [troubleshooting guide](troubleshooting.md#formatting) gives more details and explains how to [disable formatting](troubleshooting.md#disable-formatting) entirely.
106119

107120
#### Add import
108121

109122
Manually add a new import to your file through the [`Go: Add Import`](commands.md#go-add-import) command. Available packages are offered from your `GOPATH` and module cache.
110123

124+
<div style="text-align: center;"><img src="images/addimport.gif" alt="Add byte import to Go file" style="width: 75%"> </div>
125+
126+
111127
### [Rename symbol](https://code.visualstudio.com/docs/editor/refactoring#_rename-symbol)
112128

113-
Rename all occurrences of a symbol in your workspace. This feature is provided by the [`gorename`](tools.md#gorename) tool.
129+
Rename all occurrences of a symbol in your workspace.
114130

115131
**Note**: For undo after rename to work on Windows, you need to have `diff` tool on your `PATH`.
116132

117133
This feature is not available if you are using Go modules **without** [`gopls`](gopls.md), the Go language server.
118134

135+
<div style="text-align: center;"><img src="images/rename.gif" alt="Rename an exported variable in Go workspace" style="width: 75%"> </div>
136+
137+
119138
### Refactor
120139

121-
Extract a piece of code to a local variable or to its own function using the [`Go: Extract to variable`](commands.md#go-extract-to-variable) and [`Go: Extract to function`](commands.md#go-extract-to-function) commands. These features are provided by the [`godoctor`](tools.md#godoctor) tool. These features do not work with Go modules, but they will be supported by [`gopls`] in the future (see [golang/go#37170](https://github.com/golang/go/issues/37170)).
140+
Extract a piece of code to a local variable or to its own function using the [`Go: Extract to variable`](commands.md#go-extract-to-variable) and [`Go: Extract to function`](commands.md#go-extract-to-function) commands.
141+
142+
For known issues with this feature see [golang/go#37170](https://github.com/golang/go/issues/37170).
143+
144+
<div style="text-align: center;"><img src="images/extract-variable.gif" alt="Extract to variable followed by a rename" style="width: 75%"> </div>
122145

123146
## Code Generation
124147

125148
### Add or remove struct tags
126149

127150
Use the [`Go: Add Tags to Struct Fields`](commands.md#go-add-tags-to-struct-fields) command to automatically generate or remove [tags](https://pkg.go.dev/reflect?tab=doc#StructTag) for your struct. This feature is provided by the [`gomodifytags`](tools.md#gomodifytags) tool.
128151

152+
<div style="text-align: center;"><img src="images/addtagstostructfields.gif" alt="Add tags to struct fields" style="width: 75%"> </div>
153+
129154
### Generate interface implementation
130155

131156
Use the [`Go: Generate Interface Stubs`](commands.md#go-generate-interface-stubs) command to automatically generate method stubs for a given interface. This feature is provided by the [`impl`](tools.md#impl) tool.
132157

158+
<div style="text-align: center;"><img src="images/generateinterfaceimplementation.gif" alt="Generate functions to implement an interface" style="width: 75%"> </div>
159+
133160
### Generate unit tests
134161

135162
Easily generate unit tests for your project by running one of the [`Go: Generate Unit Tests for ...`](commands.md#go-generate-unit-tests-for-file) commands. This can be done at a function, file, or package level. This feature is provided by the [`gotests`](tools.md#gotests) tool.
136163

164+
<div style="text-align: center;"><img src="images/generateunittestsforfunction.gif" alt="Generate unit tests for a function" style="width: 75%"> </div>
165+
137166
### Fill struct literals
138167

139-
Use the [`Go: Fill struct`](commands.md#fill-struct) command to automatically fill a struct literal with its default values. This command is provided by the [`fillstruct`](tools.md#fillstruct).
168+
Use the [`Go: Fill struct`](commands.md#fill-struct) command to automatically fill a struct literal with its default values.
169+
170+
<div style="text-align: center;"><img src="images/fillstructliterals.gif" alt="Fill struct literals" style="width: 75%"> </div>
140171

141172
## Diagnostics
142173

@@ -178,7 +209,7 @@ Behind the scenes, the `Debug: Start without Debugging` command calls `go run`.
178209

179210
### Code Coverage
180211

181-
Show code coverage in the editor, either after running a test or on-demand. This can be done via the commands: [`Go: Apply Cover Profile`](commands.md#go-apply-cover-profile) and [`Go: Toggle Test Coverage in Current Package`](commands.go-toggle-test-coverage-in-current-package).
212+
Show code coverage in the editor, either after running a test or on-demand. This can be done via the commands: [`Go: Apply Cover Profile`](commands.md#go-apply-cover-profile) and [`Go: Toggle Test Coverage in Current Package`](commands.md#go-toggle-test-coverage-in-current-package).
182213

183214
## [Debugging](debugging.md)
184215

docs/gopath.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
# `GOPATH`
22

3-
The `GOPATH` environment variable is a fundamental part of writing Go code **without** [Go modules]. It specifies the location of your workspace, and it defaults to `$HOME/go`. A `GOPATH` directory contains `src`, `bin`, and `pkg` directories. Your code is typically located in the `$GOPATH/src` directory.
3+
The `GOPATH` environment variable is a fundamental part of writing Go code
4+
**without** [Go modules]. It specifies the location of your workspace, and it
5+
defaults to `$HOME/go`. A `GOPATH` directory contains `src`, `bin`, and `pkg`
6+
directories. Your code is typically located in the `$GOPATH/src` directory.
47

5-
If you are not familiar with Go and `GOPATH`, please first read about [writing Go code with `GOPATH`](https://golang.org/doc/gopath_code.html#GOPATH).
8+
If you are not familiar with Go and `GOPATH`, please first read about [writing
9+
Go code with `GOPATH`](https://golang.org/doc/gopath_code.html#GOPATH).
10+
11+
**If you are just starting out with Go, we recommend [using Go modules](https://blog.golang.org/using-go-modules) instead of GOPATH.**
612

713
## Overview
814

@@ -21,7 +27,7 @@ If the `GOPATH` value is incorrect, see the details below on how to configure it
2127

2228
## Setting `GOPATH`
2329

24-
If you have chosen not to use [Go modules], you will need to configure your `GOPATH`. Modules have largely eliminated the need for a `GOPATH`, so if you're interested in using them, taking a look at the [modules documentation](modules.md) for the VS Code Go extension.
30+
If you have chosen not to use [Go modules], you will need to configure your `GOPATH`.
2531

2632
Setting `GOPATH` is typically as simple as setting the environment variable once in your system's configuration. Take a look at the [Setting `GOPATH` Wiki](https://github.com/golang/go/wiki/SettingGOPATH) if you're unsure how to do this.
2733

0 commit comments

Comments
 (0)