-
Notifications
You must be signed in to change notification settings - Fork 791
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
go.alternateTools does not automatically add .exe (or similar) on Windows, missing "which" call? #3731
Comments
I think you're misunderstanding What you're asking for is not a PATH lookup. You are asking for the extension to conditionally append |
I don't think I'm misunderstanding |
Let's say that
It seems to me that the obvious solution is |
The code in
It is not uncommon to call
I think you're speaking hypothetically, but I cannot ask people to do this; it's a non-standard location specific to a repo checkout. The VS Code settings are the best place to set this and it work consistently without trying to figure out how to ensure
The resolution would also have to handle |
Hi @jakebailey Thanks for raising this issue. I agree that I would prefer setting alternateTools instead of adding this The entire binary look up logic is quite complicated in Go. I spent some time to understand this but there is still some ambiguity the require further investigation. To understand your request, today, you are adding As mentioned, the binary look up is kind of complicated in vscode go and in go. There are:
I think GOBIN is overwriting GOPATH if both are present.
Yes. I have not look deep enough but from the observation, vscode-go definitely lookup binaries on GOPATH, GOBIN and PATH. (I'm not so sure of the look up order yet). So if By reading from documentation, the I will spend more time to understand tool installation and path resolve. Refactoring those code for readability purposes and understand the situation better. But I'm not sure whether |
Yes, I would expect that you could simply write (psuedocodeish): import path from "path";
import which from "which";
function getCmd(cmd: string, gopathBin: string | undefined, gobin: string | undefined): string {
let path = "";
if (gopathBin) path += gopathBin + path.delimiter;
if (gobin) path += gobin + path.delimiter;
path += process.env.PATH;
return which.sync(cmd, { path });
} And it "just works". Though, I don't know the order either. I'd be surprised if GOPATH or GOBIN took precedence over |
This is the key point (from the documentation Hongxiang linked). It's not explicitly stated but I think it's pretty clearly implied that it means the "absolute path of the binary file", which I would interpret as the entire path including any extension that may be necessary. In other words, if a name (without slashes) is provided, it uses a lookup process, but if a path (with slashes) is provided it expects that to be a literal file path. Personally if I provide a file path I expect that path to be used as is. |
What version of Go, VS Code & VS Code Go extension are you using?
Version Information
go version
to get version of Go from the VS Code integrated terminal.go version go1.24.1 linux/amd64
gopls -v version
to get version of Gopls from the VS Code integrated terminal.golang.org/x/tools/gopls v0.31.1-0.20250324134734-bf12eb7e7db4+dirty
code -v
orcode-insiders -v
to get version of VS Code or VS Code Insiders.1.99.0-insider dc289883be5d37d5d2b2f7d30926aa42a3123437
0.47.1
Go: Locate Configured Go Tools
command.gotests: not installed
gomodifytags: not installed
impl: not installed
goplay: not installed
dlv: /home/jabaile/go/bin/dlv (version: v1.24.1 built with go: go1.24.1)
golangci-lint: /home/jabaile/work/TypeScript-go/_tools/custom-gcl (version: v1.64.6+dirty built with go: go1.24.1)
Share the Go related settings you have added/edited
Run
Preferences: Open Settings (JSON)
command to open your settings.json file.Share all the settings with the
go.
or["go"]
orgopls
prefixes.Describe the bug
In order to support users of a repo that are using all OSs, I've had to use
${env:GOEXE}
to conditionally add.exe
on Windows via the Go extension's environment variable provider when configuring ourgolangci-lint custom
built binary.It seems to me like this shouldn't be required; using a library like https://www.npmjs.com/package/which on the config would automatically net the correct path with extension for the tool.
Steps to reproduce the behavior:
go.alternateTools
without an extension on Windows.The text was updated successfully, but these errors were encountered: