From 9e19f3f7ae8422941bf5f92bbec3e19c07927c52 Mon Sep 17 00:00:00 2001 From: marcel-basel Date: Sat, 25 Jan 2020 19:10:08 +0100 Subject: [PATCH 1/3] go tools are also resolved on GOBIN path. Logging correct path on GOBIN install --- src/goInstallTools.ts | 9 ++++++--- src/goPath.ts | 9 +++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/goInstallTools.ts b/src/goInstallTools.ts index b1e095f15..b0cd6584c 100644 --- a/src/goInstallTools.ts +++ b/src/goInstallTools.ts @@ -144,9 +144,12 @@ export function installTools(missing: Tool[], goVersion: GoVersion): Promise 1 ? 'tools' : 'tool'} at ${toolsGopath}${ - path.sep - }bin`; + let binpath = toolsGopath + path.sep + "bin"; + if(envForTools['GOBIN'] != undefined && envForTools['GOBIN'] != ''){ + binpath = "GOBIN path " + envForTools['GOBIN'] + } + + let installingMsg = `Installing ${missing.length} ${missing.length > 1 ? 'tools' : 'tool'} at ${binpath}`; // If the user is on Go >= 1.11, tools should be installed with modules enabled. // This ensures that users get the latest tagged version, rather than master, diff --git a/src/goPath.ts b/src/goPath.ts index d211ef102..9ab441765 100644 --- a/src/goPath.ts +++ b/src/goPath.ts @@ -41,6 +41,15 @@ export function getBinPathWithPreferredGopath(toolName: string, preferredGopaths } const binname = alternateTool && !path.isAbsolute(alternateTool) ? alternateTool : toolName; + const env = Object.assign({}, process.env); + if (env['GOBIN'] != undefined){ + const path = getBinPathFromEnvVar(binname, env['GOBIN'], false); + if (path) { + binPathCache[toolName] = path; + return path; + } + } + for (const preferred of preferredGopaths) { if (typeof preferred === 'string') { // Search in the preferred GOPATH workspace's bin folder From 8660153af2e24cd015fde26d3b222954e2cd2c32 Mon Sep 17 00:00:00 2001 From: marcel-basel Date: Mon, 27 Jan 2020 18:25:54 +0100 Subject: [PATCH 2/3] no copy of process.env, rem. condition, ren. const --- src/goPath.ts | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/goPath.ts b/src/goPath.ts index 770627591..16770ad21 100644 --- a/src/goPath.ts +++ b/src/goPath.ts @@ -41,15 +41,12 @@ export function getBinPathWithPreferredGopath(toolName: string, preferredGopaths } const binname = alternateTool && !path.isAbsolute(alternateTool) ? alternateTool : toolName; - const env = Object.assign({}, process.env); - if (env['GOBIN'] != undefined){ - const path = getBinPathFromEnvVar(binname, env['GOBIN'], false); - if (path) { - binPathCache[toolName] = path; - return path; - } + const pathFromGoBin = getBinPathFromEnvVar(binname, process.env['GOBIN'], false); + if (pathFromGoBin) { + binPathCache[toolName] = pathFromGoBin; + return pathFromGoBin; } - + for (const preferred of preferredGopaths) { if (typeof preferred === 'string') { // Search in the preferred GOPATH workspace's bin folder From 83e3360bf56e6275bc083765cd409e025d34fa15 Mon Sep 17 00:00:00 2001 From: Ramya Achutha Rao Date: Tue, 28 Jan 2020 14:38:11 -0800 Subject: [PATCH 3/3] When using GOBIN, the message should reflect the same --- src/goInstallTools.ts | 10 +++++----- src/goPath.ts | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/goInstallTools.ts b/src/goInstallTools.ts index b0cd6584c..93b42e9a1 100644 --- a/src/goInstallTools.ts +++ b/src/goInstallTools.ts @@ -144,13 +144,13 @@ export function installTools(missing: Tool[], goVersion: GoVersion): Promise 1 ? 'tools' : 'tool'} at `; + if (envForTools['GOBIN']) { + installingMsg += `the configured GOBIN: ${envForTools['GOBIN']}`; + } else { + installingMsg += toolsGopath + path.sep + 'bin'; } - let installingMsg = `Installing ${missing.length} ${missing.length > 1 ? 'tools' : 'tool'} at ${binpath}`; - // If the user is on Go >= 1.11, tools should be installed with modules enabled. // This ensures that users get the latest tagged version, rather than master, // which may be unstable. diff --git a/src/goPath.ts b/src/goPath.ts index 16770ad21..cd89eeac0 100644 --- a/src/goPath.ts +++ b/src/goPath.ts @@ -46,7 +46,7 @@ export function getBinPathWithPreferredGopath(toolName: string, preferredGopaths binPathCache[toolName] = pathFromGoBin; return pathFromGoBin; } - + for (const preferred of preferredGopaths) { if (typeof preferred === 'string') { // Search in the preferred GOPATH workspace's bin folder