Keep the last used cover profile path (#3119)

diff --git a/src/goMain.ts b/src/goMain.ts
index eb6a69f..33cfa90 100644
--- a/src/goMain.ts
+++ b/src/goMain.ts
@@ -46,7 +46,14 @@
 import { showHideStatus } from './goStatus';
 import { testAtCursor, testCurrentFile, testCurrentPackage, testPrevious, testWorkspace } from './goTest';
 import { vetCode } from './goVet';
-import { getFromGlobalState, setGlobalState, updateGlobalState } from './stateUtils';
+import {
+	getFromGlobalState,
+	getFromWorkspaceState,
+	setGlobalState,
+	setWorkspaceState,
+	updateGlobalState,
+	updateWorkspaceState
+} from './stateUtils';
 import { disposeTelemetryReporter, sendTelemetryEventForConfig } from './telemetry';
 import { cancelRunningTests, showTestOutput } from './testUtils';
 import {
@@ -69,6 +76,7 @@
 
 export function activate(ctx: vscode.ExtensionContext): void {
 	setGlobalState(ctx.globalState);
+	setWorkspaceState(ctx.workspaceState);
 
 	updateGoPathGoRootFromConfig().then(async () => {
 		const updateToolsCmdText = 'Update tools';
@@ -471,9 +479,12 @@
 				vscode.window.showErrorMessage('Cannot apply coverage profile when no Go file is open.');
 				return;
 			}
+			const lastCoverProfilePathKey = 'lastCoverProfilePathKey';
+			const lastCoverProfilePath = getFromWorkspaceState(lastCoverProfilePathKey, '');
 			vscode.window
 				.showInputBox({
-					prompt: 'Enter the path to the coverage profile for current package'
+					prompt: 'Enter the path to the coverage profile for current package',
+					value: lastCoverProfilePath,
 				})
 				.then((coverProfilePath) => {
 					if (!coverProfilePath) {
@@ -483,6 +494,9 @@
 						vscode.window.showErrorMessage(`Cannot find the file ${coverProfilePath}`);
 						return;
 					}
+					if (coverProfilePath !== lastCoverProfilePath) {
+						updateWorkspaceState(lastCoverProfilePathKey, coverProfilePath);
+					}
 					applyCodeCoverageToAllEditors(
 						coverProfilePath,
 						path.dirname(vscode.window.activeTextEditor.document.fileName)
diff --git a/src/stateUtils.ts b/src/stateUtils.ts
index 35983c5..067cd44 100644
--- a/src/stateUtils.ts
+++ b/src/stateUtils.ts
@@ -6,6 +6,7 @@
 import vscode = require('vscode');
 
 let globalState: vscode.Memento;
+let workspaceState: vscode.Memento;
 
 export function getFromGlobalState(key: string, defaultValue?: any) {
 	if (!globalState) {
@@ -24,3 +25,21 @@
 export function setGlobalState(state: vscode.Memento) {
 	globalState = state;
 }
+
+export function getFromWorkspaceState(key: string, defaultValue?: any) {
+	if (!workspaceState) {
+		return defaultValue;
+	}
+	return workspaceState.get(key, defaultValue);
+}
+
+export function updateWorkspaceState(key: string, value: any) {
+	if (!workspaceState) {
+		return;
+	}
+	return workspaceState.update(key, value);
+}
+
+export function setWorkspaceState(state: vscode.Memento) {
+	workspaceState = state;
+}