src/config: suppress welcome page & update check in cloud-based ides

In Cloud Shell IDE or GitHub Codespace, extensions for multiple
languages can be activated and it's likely there is no extension memento
that can persist and keep track of users' responses across multiple
sessions, so presenting our welcome page upon activation isn't
desirable.

They are offered with fully managed dev containers and tools,
so they also don't want our extension to prompt and distract
users by asking to update tools again.

Survey prompts don't make much sense either in this environment
where the main target use case is quick code browsing and small
change testing.

So, disable all of them if the extension is running in Cloud Shell IDE
or GitHub Codespace. (config.ts/IsInCloudIDE)

Updates golang/vscode-go#1246

Change-Id: I6ef9754efb20a23658098870e26a56ce2c888df3
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/297690
Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
diff --git a/src/config.ts b/src/config.ts
index 4543c34..bbc44bb 100644
--- a/src/config.ts
+++ b/src/config.ts
@@ -155,3 +155,6 @@
 	}
 	return defaultConfig.get(section, uri);
 }
+
+// True if the extension is running in known cloud-based IDEs.
+export const IsInCloudIDE = process.env.CLOUD_SHELL === 'true' || process.env.CODESPACES === 'true';
diff --git a/src/goEnvironmentStatus.ts b/src/goEnvironmentStatus.ts
index 5694963..135eed1 100644
--- a/src/goEnvironmentStatus.ts
+++ b/src/goEnvironmentStatus.ts
@@ -13,7 +13,7 @@
 import os = require('os');
 import path = require('path');
 import { promisify } from 'util';
-import { getGoConfig } from './config';
+import { getGoConfig, IsInCloudIDE } from './config';
 import { toolInstallationEnvironment } from './goEnv';
 import { logVerbose } from './goLogging';
 import { addGoStatus, goEnvStatusbarItem, outputChannel, removeGoStatus } from './goStatus';
@@ -538,6 +538,9 @@
 const dismissedGoVersionUpdatesKey = 'dismissedGoVersionUpdates';
 
 export async function offerToInstallLatestGoVersion() {
+	if (IsInCloudIDE) {
+		return;
+	}
 	const goConfig = getGoConfig();
 	const checkForUpdate = getCheckForToolsUpdatesConfig(goConfig);
 	if (checkForUpdate === 'off' || checkForUpdate === 'local') {
diff --git a/src/goLanguageServer.ts b/src/goLanguageServer.ts
index 1950974..3a9241e 100644
--- a/src/goLanguageServer.ts
+++ b/src/goLanguageServer.ts
@@ -31,7 +31,7 @@
 	RevealOutputChannelOn
 } from 'vscode-languageclient';
 import { LanguageClient } from 'vscode-languageclient/node';
-import { getGoConfig, getGoplsConfig } from './config';
+import { getGoConfig, getGoplsConfig, IsInCloudIDE } from './config';
 import { extensionId } from './const';
 import { GoCodeActionProvider } from './goCodeAction';
 import { GoDefinitionProvider } from './goDeclaration';
@@ -175,6 +175,9 @@
 // update to the latest version. We also check if we should prompt users to
 // fill out the survey.
 function scheduleGoplsSuggestions() {
+	if (IsInCloudIDE) {
+		return;
+	}
 	// Some helper functions.
 	const usingGopls = (cfg: LanguageServerConfig): boolean => {
 		return cfg.enabled && cfg.serverName === 'gopls';
@@ -973,7 +976,7 @@
 
 export async function shouldUpdateLanguageServer(tool: Tool, cfg: LanguageServerConfig): Promise<semver.SemVer> {
 	// Only support updating gopls for now.
-	if (tool.name !== 'gopls' || cfg.checkForUpdates === 'off') {
+	if (tool.name !== 'gopls' || cfg.checkForUpdates === 'off' || IsInCloudIDE) {
 		return null;
 	}
 
diff --git a/src/goMain.ts b/src/goMain.ts
index ae2b9b7..45ceb32 100644
--- a/src/goMain.ts
+++ b/src/goMain.ts
@@ -9,7 +9,7 @@
 'use strict';
 
 import * as path from 'path';
-import { getGoConfig, initConfig } from './config';
+import { getGoConfig, initConfig, IsInCloudIDE } from './config';
 import { browsePackages } from './goBrowsePackage';
 import { buildCode } from './goBuild';
 import { check, notifyIfGeneratedFile, removeTestStatus } from './goCheck';
@@ -145,7 +145,9 @@
 	}
 
 	// Show the Go welcome page on update.
-	showGoWelcomePage(ctx);
+	if (!IsInCloudIDE) {
+		showGoWelcomePage(ctx);
+	}
 
 	const configGOROOT = getGoConfig()['goroot'];
 	if (configGOROOT) {