Fixes #2122 tools are also found at GOBIN path#3001
Fixes #2122 tools are also found at GOBIN path#3001ramya-rao-a merged 4 commits intomicrosoft:masterfrom
Conversation
| } | ||
|
|
||
| const binname = alternateTool && !path.isAbsolute(alternateTool) ? alternateTool : toolName; | ||
| const env = Object.assign({}, process.env); |
There was a problem hiding this comment.
What is the reason for making a copy of the env variables?
Since we are only reading the env var values, process.env can be directly used.
|
|
||
| const binname = alternateTool && !path.isAbsolute(alternateTool) ? alternateTool : toolName; | ||
| const env = Object.assign({}, process.env); | ||
| if (env['GOBIN'] != undefined){ |
There was a problem hiding this comment.
This if check can be removed. If no GOBIN is set, then getBinPathFromEnvVar() will return null anyway.
| 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); |
There was a problem hiding this comment.
Please rename to pathFromGoBin to match the patterns of pathFromGoRoot and pathFromPath names used later on
|
Commited the requested changes |
| }bin`; | ||
| let binpath = toolsGopath + path.sep + "bin"; | ||
| if(envForTools['GOBIN'] != undefined && envForTools['GOBIN'] != ''){ | ||
| binpath = "GOBIN path " + envForTools['GOBIN'] |
There was a problem hiding this comment.
If GOBIN is set, then we can essentially skip the code path
vscode-go/src/goInstallTools.ts
Lines 124 to 145 in 8660153
There was a problem hiding this comment.
We still have to set the current go path envForTools['GOPATH'] = toolsGopath; since envForTools is passed as options when go get child process is created. GOBIN is only setting the path where the executable should be installed. Right?
1f5fa4f to
83e3360
Compare

If
go.toolsGopathsetting is set,goInstallTools.installToolswas already setting GOBIN env to ''. With nogo.toolsGopathset but GOBIN defined the tools are installed in GOBIN path already. The log message had to be corrected (Installing x tools at ...).GOBIN was added to the list of places where the extension looks for the tools