commands: add go.goroot command

Add go.goroot command, similar to the existing go.gopath.

Closes golang/vscode-go#2379.

Change-Id: I4851df5406897b347dbf17bd1f35e751d6ffa85a
GitHub-Last-Rev: 0e355e9fe0c71e44ad9b72a35aa40a0c533dba44
GitHub-Pull-Request: golang/vscode-go#2381
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/419834
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
diff --git a/docs/commands.md b/docs/commands.md
index fede59f..b525b85 100644
--- a/docs/commands.md
+++ b/docs/commands.md
@@ -27,6 +27,10 @@
 
 See the currently set GOPATH.
 
+### `Go: Current GOROOT`
+
+See the currently set GOROOT.
+
 ### `Go: Locate Configured Go Tools`
 
 List all the Go tools being used by this extension along with their locations.
diff --git a/package.json b/package.json
index 1798d02..f1f24b0 100644
--- a/package.json
+++ b/package.json
@@ -95,6 +95,7 @@
     "workspaceContains:*/*.go",
     "workspaceContains:*/*/*.go",
     "onCommand:go.gopath",
+    "onCommand:go.goroot",
     "onCommand:go.tools.install",
     "onCommand:go.locate.tools",
     "onCommand:go.show.commands",
@@ -212,6 +213,11 @@
         "description": "See the currently set GOPATH."
       },
       {
+        "command": "go.goroot",
+        "title": "Go: Current GOROOT",
+        "description": "See the currently set GOROOT."
+      },
+      {
         "command": "go.locate.tools",
         "title": "Go: Locate Configured Go Tools",
         "description": "List all the Go tools being used by this extension along with their locations."
diff --git a/src/commands/getCurrentGoRoot.ts b/src/commands/getCurrentGoRoot.ts
new file mode 100644
index 0000000..cd0a5af
--- /dev/null
+++ b/src/commands/getCurrentGoRoot.ts
@@ -0,0 +1,18 @@
+/*---------------------------------------------------------
+ * Copyright 2022 The Go Authors. All rights reserved.
+ * Licensed under the MIT License. See LICENSE in the project root for license information.
+ *--------------------------------------------------------*/
+
+import * as vscode from 'vscode';
+
+import { CommandFactory } from '.';
+import { getCurrentGoRoot as utilGetCurrentGoRoot } from '../utils/pathUtils';
+
+export const getCurrentGoRoot: CommandFactory = () => {
+	return () => {
+		const goroot = utilGetCurrentGoRoot();
+		const msg = `${goroot} is the current GOROOT.`;
+		vscode.window.showInformationMessage(msg);
+		return goroot;
+	};
+};
diff --git a/src/commands/index.ts b/src/commands/index.ts
index d82ba4a..d15dffc 100644
--- a/src/commands/index.ts
+++ b/src/commands/index.ts
@@ -10,6 +10,7 @@
 export { applyCoverprofile } from './applyCoverprofile';
 export { getConfiguredGoTools } from './getConfiguredGoTools';
 export { getCurrentGoPath } from './getCurrentGoPath';
+export { getCurrentGoRoot } from './getCurrentGoRoot';
 export { extractFunction, extractVariable } from '../goDoctor';
 export { runFillStruct } from '../goFillStruct';
 export { implCursor } from '../goImpl';
diff --git a/src/goMain.ts b/src/goMain.ts
index db31bbb..a525684 100644
--- a/src/goMain.ts
+++ b/src/goMain.ts
@@ -136,6 +136,7 @@
 	ctx.subscriptions.push(goCtx.vetDiagnosticCollection);
 
 	registerCommand('go.gopath', commands.getCurrentGoPath);
+	registerCommand('go.goroot', commands.getCurrentGoRoot);
 	registerCommand('go.locate.tools', commands.getConfiguredGoTools);
 	registerCommand('go.add.tags', commands.addTags);
 	registerCommand('go.remove.tags', commands.removeTags);