You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My goal in this change was to clean up the main README and make it a bit
more welcoming. The structure is now oriented towards helping people
get started and linking all of the pages in the docs/ folder.
A lot of the current content is a bit too specific and
fits better in the docs pages, so I copy-pasted a lot of text to the
relevant pages. Follow-up CLs will involve cleaning up these other pages
and smoothing out the content there.
Change-Id: I905026d1b4efb3dbad3b7c41e2f234185dee51ed
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/236057
Reviewed-by: Hyang-Ah Hana Kim <[email protected]>
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [[email protected]](mailto:[email protected]) with any additional questions or comments.
1
+
# Code of Conduct
2
+
3
+
This project follows the [Go Community Code of Conduct](https://golang.org/conduct). If you encounter an issue, please mail [email protected].
Copy file name to clipboardExpand all lines: docs/commands.md
+57
Original file line number
Diff line number
Diff line change
@@ -29,3 +29,60 @@ One of `"gofmt"`, `"goimports"`, `"goreturns"`, and `"goformat"` (`goreturns` is
29
29
### lintTool
30
30
31
31
One of `"golint"`, `"staticcheck"`, `"golangci-lint"`, and `"revive"` (`golint` is the default). This is the tool used by the [lint-on-save](features.md#lint-on-save) feature. See more information about each of these tools in the [Diagnostics](tools.md#Diagnostics) section.
32
+
33
+
### lintFlags
34
+
35
+
This setting can be used to pass additional flags to your lint tool of choice.
36
+
37
+
Most linters can be configured via special configuration files, but you may still need to pass command-line flags. The configuration documentation for each supported linter is listed here:
Enable all [`golangci-lint`] linters and only show errors in new code:
46
+
47
+
```json5
48
+
"go.lintFlags": ["--enable-all", "--new"]
49
+
```
50
+
51
+
Configure `revive` to exclude `vendor` directories and apply extra configuration with a `config.toml` file:
52
+
53
+
```json5
54
+
"go.lintFlags": [
55
+
"-exclude=vendor/...",
56
+
"-config=${workspaceFolder}/config.toml"
57
+
]
58
+
```
59
+
60
+
### Commands
61
+
62
+
In addition to integrated editing features, the extension also provides several commands in the Command Palette for working with Go files:
63
+
64
+
*`Go: Add Import` to add an import from the list of packages in your Go context
65
+
*`Go: Current GOPATH` to see your currently configured GOPATH
66
+
*`Go: Test at cursor` to run a test at the current cursor position in the active document
67
+
*`Go: Test Package` to run all tests in the package containing the active document
68
+
*`Go: Test File` to run all tests in the current active document
69
+
*`Go: Test Previous` to run the previously run test command
70
+
*`Go: Test All Packages in Workspace` to run all tests in the current workspace
71
+
*`Go: Generate Unit Tests For Package` Generates unit tests for the current package
72
+
*`Go: Generate Unit Tests For File` Generates unit tests for the current file
73
+
*`Go: Generate Unit Tests For Function` Generates unit tests for the selected function in the current file
74
+
*`Go: Install Tools` Installs/updates all the Go tools that the extension depends on
75
+
*`Go: Add Tags` Adds configured tags to selected struct fields.
76
+
*`Go: Remove Tags` Removes configured tags from selected struct fields.
77
+
*`Go: Generate Interface Stubs` Generates method stubs for given interface
78
+
*`Go: Fill Struct` Fills struct literal with default values
79
+
*`Go: Run on Go Playground` Upload the current selection or file to the Go Playground
80
+
81
+
You can access all of the above commands from the command palette (`Cmd+Shift+P` or `Ctrl+Shift+P`).
82
+
83
+
A few of these are available in the editor context menu as an experimental feature as well. To control which of these commands show up in the editor context menu, update the setting `go.editorContextMenuCommands`.
Copy file name to clipboardExpand all lines: docs/debugging.md
+31-5
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,30 @@
1
-
## Install delve
1
+
#Debugging
2
2
3
-
There are 2 ways to install delve
4
-
- Run the command `Go: Install/Update Tools`, select `dlv`, press `Ok` to install/update delve
5
-
- Or install it manually install delve as per the [Installation Instructions](https://github.com/go-delve/delve/tree/master/Documentation/installation).
3
+
The Go debugger is [Delve]. The [Delve] repository has detailed instructions, so we recommend taking a look at the [Delve documentation](https://github.com/go-delve/delve/tree/master/Documentation).
6
4
7
-
## Set up configurations in your settings
5
+
## Table of Contents
6
+
7
+
*[Features](#features)
8
+
*[Set up](#set-up)
9
+
*[Installation](#installation)
10
+
*[Configuration](#configuration)
11
+
*[Launch Configuration](#launch-configuration)
12
+
*[Debugging in WSL](#debugging-in-wsl)
13
+
*[Remote Debugging](#remote-debugging)
14
+
*[Common Issues](#common-issues)
15
+
16
+
## Set up
17
+
18
+
[Delve] should be installed by default when you install this extension.
19
+
20
+
### Installation
21
+
22
+
You can also install it manually in one of two ways:
23
+
24
+
1. Open the Command Palette (Ctrl+Shift+P), select `Go: Install/Update Tools`, and select `dlv`.
25
+
2. Follow the [Delve installation instructions](https://github.com/go-delve/delve/tree/master/Documentation/installation).
26
+
27
+
### Configuration
8
28
9
29
The below settings are used by the debugger. You may not need to add/change any of them to have debugging working in simple cases, but do give them a read sometime
10
30
-`go.gopath`. See [GOPATH in VS Code](gopath.md)
@@ -149,6 +169,10 @@ Enter the id of the process running your executable in the below snippet
149
169
}
150
170
```
151
171
172
+
## Debugging in WSL
173
+
174
+
If using WSL on Windows, you will need the WSL 2 Linux kernel. See [WSL 2 Installation](https://docs.microsoft.com/en-us/windows/wsl/wsl2-install) and note the Window 10 build version requirements.
175
+
152
176
## Remote Debugging
153
177
154
178
To remote debug using VS Code, you must first run a headless Delve server on the target machine. The below examples assume
@@ -264,3 +288,5 @@ Check the version of delve api being used in the remote delve process i.e check
264
288
#### Try using dlv from the terminal/command-line
265
289
266
290
Add `"trace": "log"` to your debug configuration and debug in VS Code. This will send logs to the debug console where you can see the actual call being made to dlv. You can copy that and run it in your terminal
Copy file name to clipboardExpand all lines: docs/faq.md
+8-2
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
## FAQ
1
+
#Frequently Asked Questions
2
2
3
3
**Q: I installed the plugin, but none of the features are working. Why?**
4
4
@@ -32,7 +32,7 @@ If you see an error of the form `command <command-name-here> not found`, it mean
32
32
33
33
**A:** Because the formatting tools used by this extension either `goreturns`, `goimports` or `gofmt` or `gopls` all follow the default Go formatting rule of using tabs instead of spaces.
34
34
35
-
**Q: Shoudln't the formatting tools be using a tab size of 8?**
35
+
**Q: Shouldn't the formatting tools be using a tab size of 8?**
36
36
37
37
**A:** The default tab size in VS Code is 4. To change this to 8 for Go files, add the below to your settings.
38
38
```json
@@ -119,3 +119,9 @@ features.
119
119
**Q: How do I get the features/bug fixes that are implemented but not released yet? How do I get the beta version of the Go extension?**
120
120
121
121
**A:** Install the [Go Nightly](nightly.md) extension.
122
+
123
+
**Q: I am seeing out-of-date completion results.**
124
+
125
+
If you are using the language server (`"go.useLanguageServer": true`), please file a [`gopls` issue](https://github.com/golang/go/issues/new).
126
+
127
+
Otherwise, check the value of `"go.buildOnSave"`. If it is `"off"`, then you may not get fresh results from not-yet-built dependencies. Therefore, ensure you have built your dependencies manually in such cases.
Copy file name to clipboardExpand all lines: docs/features.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -160,7 +160,7 @@ The vet tool used is the one provided by the `go` command: `go vet`.
160
160
161
161
Much like vet errors, lint errors can also be shown on save. This behavior is configurable through the [`"go.lintOnSave"`](commands.md#lintOnSave) setting.
162
162
163
-
The default lint tool is the one provided by the `go` command: `go lint`. However, custom lint tools can be easily used instead by configuring the [`"go.lintTool"`](tools.md#lintTool) setting.
163
+
The default lint tool is the one provided by the `go` command: `go lint`. However, custom lint tools can be easily used instead by configuring the [`"go.lintTool"`](commands.md#lintTool) setting. To learn more about the different options, see the [documentation for diagnostic tools](tools.md#diagnostics).
# [`gopls`](golang.org/s/gopls), the Go language server
2
+
3
+
**Note: `gopls` only supports Go versions above 1.11.**
4
+
5
+
#### Install/Update the Go language server
6
+
7
+
Ideally, you would see prompts to use/install/update the language server.
8
+
Follow the prompts and the language server should get set up correctly.
9
+
If you want to manually install/update the language server,
10
+
- Ensure you have set `go.useLanguageServer` to `true` in your settings
11
+
- Use the `Go: Install/Update Tools` command, select `gopls` from the list and press Ok.
12
+
13
+
14
+
#### Settings to control the use of the Go language server
15
+
16
+
Below are the settings you can use to control the use of the language server. You need to reload the VS Code window for any changes in these settings to take effect.
17
+
18
+
- Set `go.useLanguageServer` to `true` to enable the use of language server.
19
+
- When using `gopls`, see the [recommended settings](https://github.com/golang/tools/blob/master/gopls/doc/vscode.md).
20
+
- Some of the features from the language server can be disabled if needed using the setting `go.languageServerExperimentalFeatures`. Below are the features you can thus control. By default, all are set to `true` i.e are enabled.
21
+
```json
22
+
"go.languageServerExperimentalFeatures": {
23
+
"diagnostics": true,
24
+
"documentLink": true
25
+
}
26
+
```
27
+
- Set `"go.languageServerFlags": ["-logfile", "path to a text file that exists"]` to collect logs in a log file.
28
+
- Set `"go.languageServerFlags": ["-rpc.trace"]` to see the complete rpc trace in the output panel (`View` -> `Output` -> `gopls`)
29
+
30
+
#### Provide feedback on gopls
31
+
32
+
If you find any problems using the `gopls` language server, please first check the [list of existing issues for gopls](https://github.com/golang/go/issues?q=is%3Aissue+is%3Aopen+label%3Agopls) and update the relevant ones with your case before logging a new one at https://github.com/golang/go/issues
33
+
34
+
35
+
#### Helpful links for gopls
36
+
37
+
-[Wiki for gopls](https://github.com/golang/tools/blob/master/gopls/doc/user.md)
38
+
-[Recommended settings for VSCode when using gopls](https://github.com/golang/tools/blob/master/gopls/doc/vscode.md)
39
+
-[Troubleshooting for gopls](https://github.com/golang/go/wiki/gopls#troubleshooting)
40
+
-[Known bugs with gopls](https://github.com/golang/go/wiki/gopls#known-issues)
41
+
-[Github issues for gopls](https://github.com/golang/go/issues?q=is%3Aissue+is%3Aopen+label%3Agopls)
0 commit comments