goMain: prompt Go Nightly users with a welcome message and useful links

We've created a few groups for Go Nightly users to form a community, so
prompt new users with some links to these resources. They should only
be prompted one time.

Also, update the documentation with some information about the different
groups and ways of providing feedback.

Fixes golang/vscode-go#817

Change-Id: Ibb1c3a3c4745086a552cdbc5bc87d8bf80a834ea
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/266419
Trust: Rebecca Stambler <rstambler@golang.org>
Trust: Suzy Mueller <suzmue@golang.org>
Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Suzy Mueller <suzmue@golang.org>
diff --git a/docs/nightly.md b/docs/nightly.md
index b139d98..c18fe59 100644
--- a/docs/nightly.md
+++ b/docs/nightly.md
@@ -4,8 +4,6 @@
 
 [Go Nightly] is the **preview** version of the Go extension, so it may be broken or unstable at times. The [Changelog](nightly/CHANGELOG.md) and [README](nightly/README.md) for [Go Nightly] can be found in the [docs/nightly](nightly/) directory.
 
-If you try out [Go Nightly], please file issues when you notice bugs. You can also join the maintainers in the [#vscode-dev](https://gophers.slack.com/archives/CUWGEKH5Z) channel on the [Gophers Slack](https://invite.slack.golangbridge.org/).
-
 ## Installation
 
 To use the [Go Nightly] extension (`golang.go-nightly`), you **must** first disable the standard Go extension (`golang.go`). The two are not compatible and will cause conflicts if enabled simultaneously.
@@ -16,6 +14,14 @@
 
 Once you have uninstalled or disabled the standard Go extension, search for [Go Nightly] in the VS Code Marketplace and install it instead.
 
+## Feedback
+
+If you use [Go Nightly], please share your feedback or bug reports by [filing an issue]. You can also speak to the maintainers directly in the [#vscode-dev](https://gophers.slack.com/archives/CUWGEKH5Z) channel on the [Gophers Slack].
+
+### Community
+
+Go Nightly users are encouraged to discuss issues and share feedback in the [#vscode-go-nightly](https://gophers.slack.com/archives/C01DQ2KBMNU) channel on [Gophers Slack] or on the [Go Nightly mailing list](https://groups.google.com/g/vscode-go-nightly). The VS Code Go maintainers may send communications to these channels to request feedback as well.
+
 ## Releases
 
 A new version of [Go Nightly], based on the repository's current [`master` branch](https://go.googlesource.com/vscode-go/+/refs/heads/master), will be released at least once a day between Monday and Thursday. If there are no new commits at master, a new version **will not** be released.
@@ -33,3 +39,5 @@
 **Note**: If you install an extension from a VSIX file, you will stop receiving automatic prompts when updates are released.
 
 [Go Nightly]: https://marketplace.visualstudio.com/items?itemName=golang.go-nightly
+[filing an issue]: https://github.com/golang/vscode-go/issues/new/choose
+[Gophers Slack]: https://invite.slack.golangbridge.org/
diff --git a/docs/settings.md b/docs/settings.md
index 0463534..a6c533d 100644
--- a/docs/settings.md
+++ b/docs/settings.md
@@ -29,6 +29,7 @@
 &nbsp;&nbsp;`"options": "json=omitempty"`,<br/>
 &nbsp;&nbsp;`"promptForTags": false`,<br/>
 &nbsp;&nbsp;`"tags": "json"`,<br/>
+&nbsp;&nbsp;`"template": ""`,<br/>
 &nbsp;&nbsp;`"transform": "snakecase"`,<br/>
     }
 
diff --git a/src/goLanguageServer.ts b/src/goLanguageServer.ts
index f2c2481..0ca71c7 100644
--- a/src/goLanguageServer.ts
+++ b/src/goLanguageServer.ts
@@ -93,7 +93,7 @@
 
 // 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';
+const goplsSurveyOn: boolean = isNightly();
 
 // lastUserAction is the time of the last user-triggered change.
 // A user-triggered change is a didOpen, didChange, didSave, or didClose event.
@@ -757,7 +757,7 @@
 	return time;
 };
 
-const acceptGoplsPrerelease = (extensionId === 'golang.go-nightly');
+const acceptGoplsPrerelease = isNightly();
 
 export const getLatestGoplsVersion = async (tool: Tool) => {
 	// If the user has a version of gopls that we understand,
@@ -983,7 +983,7 @@
 	// We then randomly pick a day in the rest of the month on which to prompt
 	// the user.
 	let probability = 0.01; // lower probability for the regular extension
-	if (extensionId === 'golang.go-nightly') {
+	if (isNightly()) {
 		probability = 0.0275;
 	}
 	cfg.promptThisMonth = Math.random() < probability;
@@ -1000,6 +1000,12 @@
 	return cfg;
 }
 
+// isNightly returns true if the extension ID is the extension ID for the
+// Nightly extension.
+export function isNightly(): boolean {
+	return extensionId === 'golang.go-nightly';
+}
+
 async function promptForSurvey(cfg: SurveyConfig, now: Date): Promise<SurveyConfig> {
 	const selected = await vscode.window.showInformationMessage(`Looks like you're using gopls, the Go language server.
 Would you be willing to fill out a quick survey about your experience with gopls?`, 'Yes', 'Not now', 'Never');
@@ -1189,7 +1195,7 @@
 	return Math.floor(Math.random() * (high - low + 1)) + low;
 }
 
-const timeMinute = 1000 * 60;
+export const timeMinute = 1000 * 60;
 const timeHour = timeMinute * 60;
 const timeDay = timeHour * 24;
 
diff --git a/src/goMain.ts b/src/goMain.ts
index 4bae122..78099ae 100644
--- a/src/goMain.ts
+++ b/src/goMain.ts
@@ -32,10 +32,13 @@
 	updateGoVarsFromConfig
 } from './goInstallTools';
 import {
+	isNightly,
 	languageServerIsRunning,
-	promptForLanguageServerDefaultChange, resetSurveyConfig, showServerOutputChannel,
-	showSurveyConfig, startLanguageServerWithFallback,
-	watchLanguageServerConfiguration
+	promptForLanguageServerDefaultChange,
+	resetSurveyConfig,
+	showServerOutputChannel,
+	showSurveyConfig,
+	startLanguageServerWithFallback, timeMinute, watchLanguageServerConfiguration
 } from './goLanguageServer';
 import { lintCode } from './goLint';
 import { logVerbose, setLogConfig } from './goLogging';
@@ -87,8 +90,12 @@
 	setWorkspaceState(ctx.workspaceState);
 	setEnvironmentVariableCollection(ctx.environmentVariableCollection);
 
-	if (extensionId === 'golang.go-nightly') {
+	if (isNightly()) {
 		promptForLanguageServerDefaultChange(cfg);
+
+		// For Nightly extension users, show a message directing them to forums
+		// to give feedback.
+		setTimeout(showGoNightlyWelcomeMessage, 10 * timeMinute);
 	}
 
 	const configGOROOT = getGoConfig()['goroot'];
@@ -523,6 +530,36 @@
 	});
 }
 
+async function showGoNightlyWelcomeMessage() {
+	const shown = getFromGlobalState(goNightlyPromptKey, false);
+	if (shown === true) {
+		return;
+	}
+	const prompt = async () => {
+		const selected = await vscode.window.showInformationMessage(`Thank you for testing new features by using the Go Nightly extension!
+We'd like to welcome you to share feedback and/or join our community of Go Nightly users and developers.`, 'Share feedback', 'Community resources');
+		switch (selected) {
+			case 'Share feedback':
+				await vscode.env.openExternal(vscode.Uri.parse('https://github.com/golang/vscode-go/blob/master/docs/nightly.md#feedback'));
+				break;
+			case 'Community resources':
+				await vscode.env.openExternal(vscode.Uri.parse('https://github.com/golang/vscode-go/blob/master/docs/nightly.md#community'));
+				break;
+			default:
+				return;
+		}
+		// Only prompt again if the user clicked one of the buttons.
+		// They may want to look at the other option.
+		prompt();
+	};
+	prompt();
+
+	// Update state to indicate that we've shown this message to the user.
+	updateGlobalState(goNightlyPromptKey, true);
+}
+
+const goNightlyPromptKey = 'goNightlyPrompt';
+
 export function deactivate() {
 	return Promise.all([
 		cancelRunningTests(),