Skip to content

Commit

Permalink
src/goModules.ts: open go.mod after init
Browse files Browse the repository at this point in the history
Running go mod init creates a new go.mod file in the workspace
folder. However it is currently unclear that the operation ran
or succeeded. This change logs messages to the output channel
and opens the go.mod file when the command has succeeded.

Change-Id: Ie384356612a3da58edbf3d8c7525f6d66084486d
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/322929
Trust: Suzy Mueller <[email protected]>
Run-TryBot: Suzy Mueller <[email protected]>
TryBot-Result: kokoro <[email protected]>
Reviewed-by: Hyang-Ah Hana Kim <[email protected]>
  • Loading branch information
suzmue committed Jun 7, 2021
1 parent 936ecdf commit 570a0a4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/goModules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,15 @@ export async function goModInit() {
try {
const env = toolExecutionEnvironment();
const cwd = getWorkspaceFolderPath();
outputChannel.appendLine(`Running "${goRuntimePath} mod init ${moduleName}"`);
await execFile(goRuntimePath, ['mod', 'init', moduleName], { env, cwd });
outputChannel.appendLine('Module successfully initialized. You are ready to Go :)');
vscode.commands.executeCommand('vscode.open', vscode.Uri.file(path.join(cwd, 'go.mod')));
} catch (e) {
outputChannel.appendLine(e);
outputChannel.show();
vscode.window.showErrorMessage(`Error running 'go mod init ${moduleName}': See Go output channel for details`);
vscode.window.showErrorMessage(
`Error running "${goRuntimePath} mod init ${moduleName}": See Go output channel for details`
);
}
}

0 comments on commit 570a0a4

Please sign in to comment.