You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Deciding, whether a particular file can be executed is a surprisingly convoluted problem, as evident from the implementation of exec.LookPath feature. In some cases, particularly when working on various tooling, we want to locate an executable not on the default system path, but elsewhere. Even more so, there may exist several executables, of which some may be preferred over others, due to version and other such considerations.
Therefore, I would like to propose to leverage the platform specific mechanics of exec.LookPath via a companion function:
The proposed function will do almost exactly the same thing as LookPath, but will take a list of directories as an additional argument (as opposed to predefined list in $PATH) and will return all the results instead of just the first encountered.
Implementing such a feature in a user library is cumbersome, because it requires non-trivial platform specific logic, which is already present and tested in os/exec package.
The text was updated successfully, but these errors were encountered:
Because of non-sound reason to close 6 years ago no revisiting the issue can ever be considered?
This is a tricky and widely used feature which many people got wrong in their libs.
Kind of similar to the situation with string escaping and unescaping, whereupon public API is much inferior to the internal API, yet can not be exported, because "inferior to the level of non-usability public API is already there".
@oakad Do you have new information to add that was not considered in #20081? As it says in that issue, this is a special purpose operation that few people need, and it's easy to copy the standard library code.
Deciding, whether a particular file can be executed is a surprisingly convoluted problem, as evident from the implementation of
exec.LookPath
feature. In some cases, particularly when working on various tooling, we want to locate an executable not on the default system path, but elsewhere. Even more so, there may exist several executables, of which some may be preferred over others, due to version and other such considerations.Therefore, I would like to propose to leverage the platform specific mechanics of
exec.LookPath
via a companion function:The proposed function will do almost exactly the same thing as
LookPath
, but will take a list of directories as an additional argument (as opposed to predefined list in$PATH
) and will return all the results instead of just the first encountered.Implementing such a feature in a user library is cumbersome, because it requires non-trivial platform specific logic, which is already present and tested in
os/exec
package.The text was updated successfully, but these errors were encountered: