Skip to content

Commit

Permalink
[release] prepare v0.18.0 release (2) @186ffe2
Browse files Browse the repository at this point in the history
186ffe2 CHANGELOG: change log for v0.18.0
972fb46 src/goTools: update gopls latestVersion to 0.5.1
743aca1 docs: update documentation for Go status bar
222e0d0 package.json: recognize gopls.mod as a go.mod file
c9b9618 src/debugAdapter: log all the env vars passed to dlv
4af2ecc src/goInstallTools: use the 'go' command from GOROOT/bin for tool install
f0c87a6 src/util,goInstallTools: log 'cwd'
b712568 src/goMain: change gopls_gc_details to gopls.gc_details
76e3f4c src/goLanguageServer: add survey config inspection commands
b44ecdb Revert "src/goLanguageServer: enable survey for the go extension users"

Change-Id: I7d62cf3518d7847b5c2dda52af4eacf3a933a6d3
  • Loading branch information
hyangah committed Oct 21, 2020
2 parents 5a991c1 + 186ffe2 commit 6e0dbec
Show file tree
Hide file tree
Showing 15 changed files with 168 additions and 36 deletions.
38 changes: 38 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,41 @@
## v0.18.0 - 23rd Oct, 2020

Unified Go status UI ⚡, many debugger feature improvements, and LSP 3.16 features! A list of all issues fixed with this release can be found in the [v0.18.0 milestone](https://github.com/golang/vscode-go/milestone/11).

### New Features
- The new Go status bar provides a menu to manage the go version, open the gopls trace, open the `go.mod` file, and more. The old `Go Modules` status bar was removed in favor of this new unified status bar. See [VS Code Go UI documentation](https://github.com/golang/vscode-go/blob/master/docs/ui.md) to learn more about this.
- New `Go: Toggle gc details` command toggles the display of compiler optimization choice for the open Go source file ([CL 256658](https://go-review.googlesource.com/c/vscode-go/+/256658)).
- Upgraded LSP to [`3.16`](https://microsoft.github.io/language-server-protocol/specifications/specification-3-16/#whatIsNew). Users of recent `gopls` can access new features such as [`Call hierarchy`](https://code.visualstudio.com/updates/v1_33#_call-hierarchy) and [`Semantic tokens`](https://code.visualstudio.com/api/language-extensions/semantic-highlight-guide#semantic-token-provider).

### Enhancement

- Debugging:
* Correctly presents the reason when the debugged program stops due to `panic` and `fatal error` ([Issue 648](https://github.com/golang/vscode-go/issues/649)).
* Be explicit about conditional breakpoint support ([Issue 781](https://github.com/golang/vscode-go/issues/781)).
* Debug Adapter logs all the environment variables passed to dlv when verbose logging is enabled.
- Language Server Client: sends `gopls` config as LSP initialization options for correct workspace symbols computation ([CL 259138](https://go-review.googlesource.com/c/vscode-go/+/259138)).
- Snippets: adds a placeholder for the `for` statement snippet ([Issue 734](https://github.com/golang/vscode-go/issues/734)).
- Excludes `vendor` directories from `go.inferGopath` disable mechanism ([Issue 301](https://github.com/golang/vscode-go/issues/301)).
- New `go.logging.level` setting allows extra logging to help debugging extension issues ([CL 256557](https://go-review.googlesource.com/c/vscode-go/+/256557)).
- For Nightly extension users, `Go: Show Survey Config` and `Go: Reset Survey Config` commands are available.

### Fixes
- Fixed the bug that caused the debug adapter to leave bogus null items in the map type variable presentation ([Issue 199](https://github.com/golang/vscode-go/issues/199)).
- Fixed several debug adapter bugs that caused remote debug to hang ([Issue 740](https://github.com/golang/vscode-go/issues/740), [766](https://github.com/golang/vscode-go/issues/766), [761](https://github.com/golang/vscode-go/issues/761), [764](https://github.com/golang/vscode-go/issues/764)).
- Restored the correct handling of language server configuration change when users opt for enabling language server and installing `gopls`. ([CL 258997](https://go-review.googlesource.com/c/vscode-go/+/258997)).
- Fixed a diagnostics error visualization issue when multiple files with errors are open ([Issue 743](https://github.com/golang/vscode-go/issues/743)).
- Changed the dependency tool installation to use the `go` command chosen from the current `GOROOT/bin`. This helps avoid using a different version of `go` command for `asdf` or `direnv` users ([Issue 757](https://github.com/golang/vscode-go/issues/757)).

### Documentation
- Documented the current limitation of symlink support in debugging ([CL 257204](https://go-review.googlesource.com/c/vscode-go/+/257204)), improved the instruction for CLI application debugging ([CL 259677](https://go-review.googlesource.com/c/vscode-go/+/259677)), and fixed syntax errors in example task configuration snippets ([CL 259077](https://go-review.googlesource.com/c/vscode-go/+/259077)).

### Code Health
- Added an initial set of tests for debug adapters ([Issue 137](https://github.com/golang/vscode-go/issues/137)). We will keep working to improve our test coverage.

### Thanks

Thank you for your contributions, @suzmue, @vologab, @amitlevy21, @danielhelfand, @egonk, @quoctruong, @polinasok, @pjweinbgo, @stamblerre, @hyangah!

## v0.17.2 - 29th Sep, 2020

### Fixes
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ You should immediately see a prompt in the bottom-right corner of your screen ti

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.

When the extension is active, you should see the [Go status bar](docs/ui.md) in the bottom left corner.

### Start coding

You're ready to Go!
Expand Down
8 changes: 8 additions & 0 deletions docs/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,11 @@ Restart the running instance of the language server
### `Go: Choose Go Environment`

Choose a different Go version or binary for this project. (WIP)

### `Go: Show Survey Configuration`

Show the current Go survey configuration

### `Go: Reset Survey Configuration`

Reset the current Go survey configuration history
17 changes: 0 additions & 17 deletions docs/go-version.md

This file was deleted.

Binary file added docs/images/gopls.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/selectGoVersion.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/statusbarmenu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 45 additions & 0 deletions docs/ui.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Extension UI

## Using The Go Status Bar

The Go status bar appears in the lower left of the extension window. Clicking the Go status bar brings up a menu that provides easy access to see and update important information about your Go project. This includes information about the Go environment, the current Go version, the `gopls` trace, and about the current module.

<div style="text-align: center;"><img src="images/statusbarmenu.png" alt="vscode extension after Go status bar item is clicked" style="width:75%" > </div>

### Go Environment

The `Go Locate Configured Go Tools` command will display the configured GOPATH, GOROOT, tool locations and the results of `go env` in the output window.

### Managing Your Go Version

You can view the current Go version by looking at the status bar item in the bottom left corner of VS Code. Clicking this button and selecting `Choose Go Environment` will present you with a menu from which you can select any version of Go that exists in your $HOME/sdk directory or on <https://golang.org/dl>. This command is also available through the command pallette using `Go: Choose Go Environment`.

Previously, the `go.goroot` and `go.alternateTools` settings controlled the Go version used by VS Code Go. If you have configured these settings, they are no longer needed and should be deleted.

<div style="text-align: center;"><img src="images/selectGoVersion.png" alt="command pallete menu for selecting a new Go version" style="width:75%" > </div>


The "Clear Selection" option resets your Go version to the one found first in either `go.alternateTools`, `go.goroot` or your PATH.

### Installing a New Go Version

After selecting any Go version that has not yet been installed (such as Go 1.14.6 in the screenshot above), the binary will be automatically installed in $HOME/sdk and put to use in your environment.

Once the download completes, VS Code Go will make use of this new Go version.

### Language Server Status

`gopls` is the official Go [language server](https://langserver.org/) developed by the Go team. It was developed in response to the release of [Go modules](docs/modules.md), and it is the recommended approach when working with [Go modules](docs/modules.md) in VS Code.

When `gopls` is enabled, :zap: is displayed next to the Go version in the status bar and the `gopls` version is displayed in the menu.

<div style="text-align: center;"><img src="images/gopls.png" alt="command pallete menu for selecting a new Go version" style="width:100px" > </div>

Selecting `Open 'gopls' trace` will open the trace of the `gopls` server in the output window. Please include this trace when filing an issue related to the extension and `gopls` is enabled.

### Modules Status

When modules are enabled for the file you have open, you can navigate to the `go.mod` file for the project using the menu. If you do not see the `Open go.mod` item, then the extension does not think the file you have open belongs to a module.

More information about [using Go modules](https://blog.golang.org/using-go-modules) is available on the Go blog.

13 changes: 12 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@
{
"id": "go.mod",
"extensions": [
"go.mod"
"go.mod",
"gopls.mod"
],
"aliases": [
"Go Module File"
Expand Down Expand Up @@ -365,6 +366,16 @@
"command": "go.environment.choose",
"title": "Go: Choose Go Environment",
"description": "Choose a different Go version or binary for this project. (WIP)"
},
{
"command": "go.survey.showConfig",
"title": "Go: Show Survey Configuration",
"description": "Show the current Go survey configuration"
},
{
"command": "go.survey.resetConfig",
"title": "Go: Reset Survey Configuration",
"description": "Reset the current Go survey configuration history"
}
],
"breakpoints": [
Expand Down
11 changes: 7 additions & 4 deletions src/debugAdapter/goDebug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import {
getCurrentGoWorkspaceFromGOPATH,
getInferredGopath,
} from '../utils/pathUtils';
import {killProcessTree} from '../utils/processUtils';
import { killProcessTree } from '../utils/processUtils';

const fsAccess = util.promisify(fs.access);
const fsUnlink = util.promisify(fs.unlink);
Expand Down Expand Up @@ -473,7 +473,11 @@ export class Delve {
log(`Using GOPATH: ${env['GOPATH']}`);
log(`Using GOROOT: ${this.goroot}`);
log(`Using PATH: ${env['PATH']}`);

if (launchArgs.trace === 'verbose') {
Object.keys(env).forEach((key) => {
log(' export ' + key + '="' + env[key] + '"');
});
}
if (!!launchArgs.noDebug) {
if (mode === 'debug') {
this.noDebug = true;
Expand Down Expand Up @@ -529,8 +533,7 @@ export class Delve {

if (!existsSync(launchArgs.dlvToolPath)) {
log(
`Couldn't find dlv at the Go tools path, ${process.env['GOPATH']}${
env['GOPATH'] ? ', ' + env['GOPATH'] : ''
`Couldn't find dlv at the Go tools path, ${process.env['GOPATH']}${env['GOPATH'] ? ', ' + env['GOPATH'] : ''
} or ${envPath}`
);
return reject(
Expand Down
12 changes: 9 additions & 3 deletions src/goInstallTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import {
GoVersion,
rmdirRecursive,
} from './util';
import { envPath, getCurrentGoRoot, getToolFromToolPath, setCurrentGoRoot } from './utils/pathUtils';
import { correctBinname, envPath, getCurrentGoRoot, getToolFromToolPath, setCurrentGoRoot } from './utils/pathUtils';

// declinedUpdates tracks the tools that the user has declined to update.
const declinedUpdates: Tool[] = [];
Expand Down Expand Up @@ -201,6 +201,11 @@ export async function installTool(
} else {
envForTools['GO111MODULE'] = 'off';
}
// Some users use direnv-like setup where the choice of go is affected by
// the current directory path. In order to avoid choosing a different go,
// we will explicitly use `GOROOT/bin/go` instead of goVersion.binaryPath
// (which can be a wrapper script that switches 'go').
const goBinary = path.join(getCurrentGoRoot(), 'bin', correctBinname('go'));

// Build the arguments list for the tool installation.
const args = ['get', '-v'];
Expand Down Expand Up @@ -231,8 +236,9 @@ export async function installTool(
cwd: toolsTmpDir,
};
const execFile = util.promisify(cp.execFile);
const { stdout, stderr } = await execFile(goVersion.binaryPath, args, opts);
const { stdout, stderr } = await execFile(goBinary, args, opts);
output = `${stdout} ${stderr}`;
logVerbose(`install: %s %s\n%s%s`, goBinary, args.join(' '), stdout, stderr);

// TODO(rstambler): Figure out why this happens and maybe delete it.
if (stderr.indexOf('unexpected directory layout:') > -1) {
Expand Down Expand Up @@ -368,7 +374,7 @@ export function updateGoVarsFromConfig(): Promise<void> {
{ env: toolExecutionEnvironment(), cwd: getWorkspaceFolderPath() },
(err, stdout, stderr) => {
if (err) {
outputChannel.append(`Failed to run '${goRuntimePath} env' : ${err}\n${stderr}`);
outputChannel.append(`Failed to run '${goRuntimePath} env' (cwd: ${getWorkspaceFolderPath()}): ${err}\n${stderr}`);
outputChannel.show();

vscode.window.showErrorMessage(`Failed to run '${goRuntimePath} env. The config change may not be applied correctly.`);
Expand Down
33 changes: 30 additions & 3 deletions src/goLanguageServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import { GoDocumentSymbolProvider } from './goOutline';
import { GoReferenceProvider } from './goReferences';
import { GoRenameProvider } from './goRename';
import { GoSignatureHelpProvider } from './goSignature';
import { updateLanguageServerIconGoStatusBar } from './goStatus';
import { outputChannel, updateLanguageServerIconGoStatusBar } from './goStatus';
import { GoCompletionItemProvider } from './goSuggest';
import { GoWorkspaceSymbolProvider } from './goSymbol';
import { getTool, Tool } from './goTools';
Expand Down Expand Up @@ -86,6 +86,10 @@ let defaultLanguageProviders: vscode.Disposable[] = [];
// server.
let restartCommand: vscode.Disposable;

// When enabled, users may be prompted to fill out the gopls survey.
// For now, we turn it on in the Nightly extension to test it.
const goplsSurveyOn: boolean = extensionId === 'golang.go-nightly';

// lastUserAction is the time of the last user-triggered change.
// A user-triggered change is a didOpen, didChange, didSave, or didClose event.
let lastUserAction: Date = new Date();
Expand Down Expand Up @@ -138,7 +142,7 @@ function scheduleGoplsSuggestions(tool: Tool) {
setTimeout(survey, timeDay);

const cfg = buildLanguageServerConfig();
if (!cfg.enabled) {
if (!goplsSurveyOn || !cfg.enabled) {
return;
}
maybePromptForGoplsSurvey();
Expand Down Expand Up @@ -1001,8 +1005,31 @@ function getSurveyConfig(): SurveyConfig {
}
}

export async function showSurveyConfig() {
outputChannel.appendLine('Gopls Survey Configuration');
outputChannel.appendLine(JSON.stringify(getSurveyConfig(), null, 2));
outputChannel.show();

const selected = await vscode.window.showInformationMessage(`Maybe prompt for survey?`, 'Yes', 'No');
switch (selected) {
case 'Yes':
maybePromptForGoplsSurvey();
break;
default:
break;
}
}

export function resetSurveyConfig() {
flushSurveyConfig(null);
}

function flushSurveyConfig(cfg: SurveyConfig) {
updateGlobalState(goplsSurveyConfig, JSON.stringify(cfg));
if (cfg) {
updateGlobalState(goplsSurveyConfig, JSON.stringify(cfg));
} else {
updateGlobalState(goplsSurveyConfig, null); // reset
}
}

// errorKind refers to the different possible kinds of gopls errors.
Expand Down
10 changes: 9 additions & 1 deletion src/goMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ import {
import {
languageServerIsRunning,
promptForLanguageServerDefaultChange,
resetSurveyConfig,
showSurveyConfig,
startLanguageServerWithFallback, watchLanguageServerConfiguration
} from './goLanguageServer';
import { lintCode } from './goLint';
Expand Down Expand Up @@ -462,7 +464,7 @@ export function activate(ctx: vscode.ExtensionContext) {
}
vscode.commands.executeCommand('gc_details', doc)
.then(undefined, (reason0) => {
vscode.commands.executeCommand('gopls_gc_details', doc)
vscode.commands.executeCommand('gopls.gc_details', doc)
.then(undefined, (reason1) => {
vscode.window.showErrorMessage(`"Go: Toggle gc details" command failed: gc_details:${reason0} gopls_gc_details:${reason1}`);
});
Expand Down Expand Up @@ -507,6 +509,12 @@ export function activate(ctx: vscode.ExtensionContext) {
})
);

// Survey related commands
ctx.subscriptions.push(
vscode.commands.registerCommand('go.survey.showConfig', () => showSurveyConfig()));
ctx.subscriptions.push(
vscode.commands.registerCommand('go.survey.resetConfig', () => resetSurveyConfig()));

vscode.languages.setLanguageConfiguration(GO_MODE.language, {
wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\@\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g
});
Expand Down
8 changes: 4 additions & 4 deletions src/goTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,10 +341,10 @@ export const allToolsInformation: { [key: string]: Tool } = {
isImportant: false,
description: 'Language Server from Google',
minimumGoVersion: semver.coerce('1.12'),
latestVersion: semver.coerce('0.4.1'),
latestVersionTimestamp: moment('2020-05-13', 'YYYY-MM-DD'),
latestPrereleaseVersion: semver.coerce('0.4.1'),
latestPrereleaseVersionTimestamp: moment('2020-05-13', 'YYYY-MM-DD'),
latestVersion: semver.coerce('0.5.1'),
latestVersionTimestamp: moment('2020-09-30', 'YYYY-MM-DD'),
latestPrereleaseVersion: semver.coerce('0.5.1'),
latestPrereleaseVersionTimestamp: moment('2020-09-30', 'YYYY-MM-DD'),
},
'dlv': {
name: 'dlv',
Expand Down
7 changes: 4 additions & 3 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,11 +348,12 @@ export async function getGoVersion(goBinPath?: string): Promise<GoVersion | unde
}
warn(`cached Go version (${JSON.stringify(cachedGoVersion)}) is invalid, recomputing`);
}
const docUri = vscode.window.activeTextEditor?.document.uri;
const cwd = getWorkspaceFolderPath(docUri && docUri.fsPath.endsWith('.go') ? docUri : undefined);

let goVersion: GoVersion;
try {
const env = toolExecutionEnvironment();
const docUri = vscode.window.activeTextEditor?.document.uri;
const cwd = getWorkspaceFolderPath(docUri && docUri.fsPath.endsWith('.go') ? docUri : undefined);
const execFile = util.promisify(cp.execFile);
const { stdout, stderr } = await execFile(goRuntimePath, ['version'], { env, cwd });
if (stderr) {
Expand All @@ -361,7 +362,7 @@ export async function getGoVersion(goBinPath?: string): Promise<GoVersion | unde
}
goVersion = new GoVersion(goRuntimePath, stdout);
} catch (err) {
warn(`failed to run "${goRuntimePath} version": ${err}`);
warn(`failed to run "${goRuntimePath} version": ${err} cwd: ${cwd}`);
return;
}
if (!goBinPath) { // if getGoVersion was called with a given goBinPath, don't cache the result.
Expand Down

0 comments on commit 6e0dbec

Please sign in to comment.