Skip to content

Commit 2300467

Browse files
committed
[release] docs: update troubleshooting documentation
Update a few broken links and create a comprehensive troubleshooting guide. Still needs more detail, particularly since the gopls, modules, and GOPATH documentation is still missing. I'd love to delete the FAQ entirely -- anything worth saying should already be in the documentation, so the information should just be made more accessible. I tried to delete as much as possible, but some leftovers will still have to be cleaned up in follow-up CLs. I'll convert that section to "Known issues" which is more helpful. Change-Id: Ie7073f9548cdbfe34af42f04d9ce5136eb1070b7 Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/236757 Reviewed-by: Hyang-Ah Hana Kim <[email protected]> (cherry picked from commit cf9d16b) Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/236959
1 parent b3751f4 commit 2300467

File tree

13 files changed

+497
-337
lines changed

13 files changed

+497
-337
lines changed

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
"${workspaceFolder}/out/test/unit"
8989
],
9090
"internalConsoleOptions": "openOnSessionStart"
91-
}
91+
},
9292
],
9393
"compounds": [
9494
{

README.md

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,17 @@ Take a look at the [Changelog](CHANGELOG.md) to learn about new features.
1313
## Overview
1414

1515
* [Getting started](#getting-started)
16+
* [Support for Go modules](#support-for-go-modules)
1617
* [Features](#features)
1718
* [Debugging](#debugging)
1819
* [Customization](#customization)
1920
* [Linter](#linter)
2021
* [GOPATH](#gopath)
21-
* [Language Server](#language-server)
22+
* [Language server](#language-server)
2223
* [Troubleshooting](docs/troubleshooting.md)
23-
* [Frequently Asked Questions (FAQ)](docs/faq.md)
24-
* [Resources](#resources)
24+
* [Ask for help](#ask-for-help)
25+
* [Preview version](#preview-version)
2526
* [Contributing](#contributing)
26-
* [Code of Conduct](#code-of-conduct)
27-
* [License](#license)
2827

2928
## Getting started
3029

@@ -46,6 +45,8 @@ Here are some additional resources for learning about how to set up your Go proj
4645

4746
**NOTE: If you are using modules, we recommend using the Go [language server](#language-server), which is explained below.**
4847

48+
More advanced users may be interested in using different `GOPATH`s or Go versions per-project. You can learn about the different `GOPATH` manipulation options in the [`GOPATH` documentation](gopath.md). Take a look at the other [customization](#customization) options as well.
49+
4950
### Install the extension
5051

5152
If you haven't already done so, install and open [Visual Studio Code](https://code.visualstudio.com). Navigate to the Extensions pane (Ctrl+Shift+X). Search for "Go" and install this extension (the publisher ID is "golang.Go").
@@ -56,11 +57,19 @@ To activate the extension, open any directory or workspace containing Go code.
5657

5758
You should immediately see a prompt in the bottom-right corner of your screen titled `Analysis Tools Missing`. This extension relies on a suite of [command-line tools](docs/tools.md), which must be installed separately from the extension. Accept the prompt, or use the `Go: Install/Update Tools` command to pick which tools you would like to install. Note that you must have [`git`](https://git-scm.com/) installed.
5859

60+
If you see an error that looks like `command Go: Install/Update Tools not found`, it means that the extension has failed to activate and register its commands. Please uninstall and then reinstall the extension.
61+
5962
### Start coding
6063

6164
You're ready to Go!
6265

63-
Be sure to learn more about the many [features](#features) of this extension, as well as how to [customize](#customization) them. See [Troubleshooting](docs/troubleshooting.md), [FAQ](docs/faq.md), and [Resources](#resources) for further guidance.
66+
Be sure to learn more about the many [features](#features) of this extension, as well as how to [customize](#customization) them. Take a look at [Troubleshooting](docs/troubleshooting.md) and [Resources](#resources) for further guidance.
67+
68+
## Support for Go modules
69+
70+
[Go modules](https://blog.golang.org/using-go-modules) have added a lot of complexity to the way most tools and features are built for Go. This has also added a lot of latency to most of the features. Some, but not all, [features](features.md) of this extension have been updated to work with Go modules. Some features may be slower in module mode. The [features documentation](features.md) contains more specific details.
71+
72+
**In general, we recommend using [gopls, the official Go language server](#language-server), if you are using modules.** Read more [below](#language-server) and in the [gopls](gopls.md) documentation.
6473

6574
## [Features](docs/features.md)
6675

@@ -104,12 +113,16 @@ To opt-in to the language server, set [`"go.useLanguageServer"`](docs/commands.m
104113

105114
For more information, see the [`gopls` documentation](docs/gopls.md).
106115

107-
## Resources
116+
## Ask for help
108117

109118
If you're having issues with this extension, please reach out to us by [filing an issue](https://github.com/golang/vscode-go/issues/new/choose) or asking a question on the [Gophers Slack]. We hang out in the `#vscode` channel!
110119

111120
Take a look at [learn.go.dev](https://learn.go.dev) and [golang.org/help](https://golang.org/help) for additional guidance.
112121

122+
## [Preview version](nightly.md)
123+
124+
If you'd like to get early access to new features and bug fixes, you can use the nightly build of this extension. Learn how to install it in by reading the [Go Nightly documentation](nightly.md).
125+
113126
## [Contributing](docs/contributing.md)
114127

115128
We welcome your contributions and thank you for working to improve the Go development experience in VS Code. If you would like to help work on the VS Code Go extension, please see our [Contribution guide](docs/contributing.md). It explains how to build and run the extension locally, as well as the process of sending a contribution.
@@ -118,7 +131,7 @@ We welcome your contributions and thank you for working to improve the Go develo
118131

119132
This project follows the [Go Community Code of Conduct](https://golang.org/conduct). If you encounter an issue, please mail [email protected].
120133

121-
## License
134+
## [License](LICENSE)
122135

123136
[MIT](LICENSE)
124137

docs/contributing.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ This guide will explain the process of setting up your development environment t
66

77
* [Before you start coding](#before-you-start-coding)
88
* [Ask for help](#ask-for-help)
9+
* [Debug Adapter](#debug-adapter)
910
* [Developing](#developing)
1011
* [Setup](#setup)
1112
* [Run](#run)
1213
* [Test](#test)
1314
* [Sideload](#sideload)
15+
1416
* [Mail your change for review](#mail-your-change-for-review)
1517

1618
## Before you start coding
@@ -23,12 +25,16 @@ If you wish to work on an existing issue, please add a comment saying so, as som
2325

2426
The VS Code Go maintainers are reachable via the issue tracker and the [#vscode-dev] channel on the [Gophers Slack]. Please reach out on Slack with questions, suggestions, or ideas. If you have trouble getting started on an issue, we'd be happy to give pointers and advice.
2527

28+
### Debug Adapter
29+
30+
Please note that extra configuration is required to build and run the [Debug Adapter](debug-adapter.md), which controls the debugging features of this extension. Refer to [the documentation for the Debug Adapter](debug-adapter.md) to set that up.
31+
2632
## Developing
2733

2834
### Setup
2935

3036
1) Install [node](https://nodejs.org/en/).
31-
2) Clone the repository, run `npm install` and open VS Code:
37+
2) Clone the repository, run `npm install`, and open VS Code:
3238

3339
```bash
3440
git clone https://github.com/golang/vscode-go
@@ -37,8 +43,8 @@ The VS Code Go maintainers are reachable via the issue tracker and the [#vscode-
3743
code .
3844
```
3945

40-
3) Make sure the `window.ope
41-
nFoldersInNewWindow` setting is not `"on"`. <!--TODO(rstambler): Confirm that this is still required.-->
46+
3) Make sure the `window.openFoldersInNewWindow` setting is not `"on"`.
47+
<!--TODO(rstambler): Confirm that this is still required.-->
4248

4349
### Run
4450

@@ -50,8 +56,6 @@ You can also set breakpoints, which will work as you run the extension.
5056
5157
If you make further edits in the codebase, you can reload (`Ctrl+R`) the `[Extension Development Host]` instance of VS Code, which will load the new code. The debugging instance will automatically reattach.
5258
53-
To debug the Go debugger, see the [debugAdapter README](../src/debugAdapter/README.md).
54-
5559
## Test
5660
5761
There are currently three test launch configurations: (1) Launch Extension Tests, (2) Launch Extension Tests with Gopls, and (3) Launch Unit Tests. To run the tests locally, open the Run view (`Ctrl+Shift+D`), select the relevant launch configuration, and hit the Play button (`F5`).

docs/debug-adapter.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Debug Adapter
2+
3+
The [Debug Adapter](../src/debugAdapter) runs in a separate Node.js process, which is spawned by VS Code when you debug Go code.
4+
5+
Please see the [Debug Adapter Protocol (DAP)](https://microsoft.github.io/debug-adapter-protocol/) to understand how the Debug Adapter acts as an intermediary between VS Code and the debugger ([Delve](https://github.com/go-delve/delve)).
6+
7+
This codebase is currently in flux: We are working on using's [`Delve`'s native DAP implementation](https://github.com/go-delve/delve/tree/master/service/dap) instead of this one. Follow along with [golang/vscode-go#23](https://github.com/golang/vscode-go/issues/23) for updates on that work.
8+
9+
## Overview
10+
11+
* [Before you begin](#before-you-begin)
12+
* [Debug only the Debug Adapter](#debug-only-the-debug-adapter)
13+
* [Debug the VS Code extension and the Debug Adapter](#debug-the-entire-extension-including-the-debug-adapter)
14+
* [Debug VS Code and the Debug Adapter](#debug-vs-code-and-the-debug-adapter)
15+
16+
## Before you begin
17+
18+
Before you start working on your change, please read the [Contribution guidelines](contributing.md). This document assumes that you are already familiar with the process of [building](contributing.md#build), [running](contributing.md#run), and [sideloading](contributing.md#sideload) the VS Code Go extension.
19+
20+
## Debug only the Debug Adapter
21+
22+
As a next step, you may want to debug the Debug Adapter, in order to understand how your change work with [`Delve`](tools.md#delve).
23+
24+
**NOTE: Since the Debug Adapter runs in a separate process from the rest of the extension, the steps below only enable you to debug the Debug Adapter code, not the entire extension. To debug the entire extension, as well as the debug adapter, see the instructions [below](#debug-the-entire-extension).**
25+
26+
1. Open the `vscode-go` folder in VS Code.
27+
2. Go the Run view and choose the `Launch as server` debug configuration.
28+
3. Add breakpoints as needed to the [`vscode-go/src/debugAdapter/goDebug.ts`](../src/debugAdapter/goDebug.ts) file.
29+
4. Open another instance of VS Code and open the Go project to debug.
30+
5. Create a debug configuration for the Go project if it doesn't exist. Set `"debugServer": 4711` in the root of the configuration.
31+
6. Start debugging your Go program using this configuration. This will trigger the breakpoints in `goDebug.ts` file.
32+
33+
## Debug the entire extension, including the Debug Adapter
34+
35+
You should take this step if your change modifies both the Debug Adapter and the main extension. This setup requires three instances of VS Code.
36+
37+
1. Open the root [`vscode-go`](../) folder in one instance of VS Code.
38+
2. Choose the `Launch Extension` debug target and run it (F5). This will launch the second instance of VS Code.
39+
3. In this second instance, open the Go application you'd like to debug. Here, as above, create a debug configuration pointing to the program you want to debug. Add `"debugServer": 4711` to the root of the configuration.
40+
4. Open a third instance of VS Code an the [`vscode-go/src/debugAdapter`](../src/debugAdapter) folder. In this instance, select the `Launch as server` configuration and run it (F5).
41+
5. Return to the second VS Code instance with the Go program. Run the debug configuration (F5). Debuggers from the other two VS Code windows are attached to the Go debug adapter and the Go language integration respectively, so you can set breakpoints, step through code and inspect state as needed.
42+
43+
<!--TODO(rstambler): Do we need to delete the src/debugAdapter/.vscode/launch.json file?-->
44+
45+
## Debug VS Code and the Debug Adapter
46+
47+
In some very rare cases, you may find it helpful to debug VS Code itself. Examples of such cases include veryfing workbench behavior and state before executing debug adapter API calls.
48+
49+
First, ensure that you can [build and run VS Code](https://github.com/Microsoft/vscode/wiki/How-to-Contribute#build-and-run) from source successfully.
50+
51+
Next, follow these steps:
52+
53+
1. Open an instance of VS Code, which you have built from source.
54+
2. [Sideload](contributing.md#sideload) your local `vscode-go` extension to the local instance of VS. This can be done by copying the contents of the vscode-go folder into `$HOME/.vscode-oss-dev/extensions/ms-vscode.go` (the exact location may vary by OS).
55+
3. Open the `vscode` folder in Visual Studio Code.
56+
4. Launch the VS Code debug instance (OSS - Code) by choosing the `Launch VS Code` debug configuraion from the drop-down in the Run view. Add a breakpoints as needed.
57+
5. In another instance of VS Code, open the [`vscode-go`](../) folder. Choose the `Launch as server` debug configuration in the Run view. Add breakpoints as desired in the [`vscode-go/src/debugAdapter/goDebug.ts`](../src/debugAdapter/goDebug.ts) file.
58+
6. Open the Go application that you want to debug in the OSS Code instance initiated in step 4.
59+
7. Create a debug configuration with the setting `"debugServer": 4711` in the root.
60+
8. Start debugging your Go application. Observe that any breakpoints you set in the VS Code and debug adapter codebases will be triggered.

0 commit comments

Comments
 (0)