Giter Club home page Giter Club logo

Comments (5)

ashleyprimo avatar ashleyprimo commented on July 19, 2024 1

This could be solved using something such as path, err := exec.LookPath("binary")- I'll submit a PR for this (likely on Monday) if this is still open 👍

from ha_cluster_exporter.

diegoakechi avatar diegoakechi commented on July 19, 2024

Great @ashleyprimo. Thanks!

from ha_cluster_exporter.

MalloZup avatar MalloZup commented on July 19, 2024

regarding PR and issue, I'm not sure if we are embarking on the good direction. Imho we should just use command.exec. https://golang.org/pkg/os/exec/#Command

In fact we are doing what already the command do , if you look at upstream doc:

If name contains no path separators, Command uses LookPath to resolve name to a complete path if possible. Otherwise it uses name directly as Path. ```

IMHO the best approach would to remove the OS.stat and check if binary, steps and execute the cmd.exec, which will already uses LookPat.  If this fail, we can just adapt the error message that either binary was not found or the binary whatsoever wasn't executable. But this will allow us to be more clean without to many checks which we can spare imho in this scenario. (since cmd.exec uses already)

from ha_cluster_exporter.

ashleyprimo avatar ashleyprimo commented on July 19, 2024

This is a very good point, makes sense that it would revert to LookPath natively; however, if were to just rely on the exec we would lose the ability to check if it's able to find the binary and if the binary is executable - since os.Stat relies on an absolute path.

Unless I'm missing something? 😃

from ha_cluster_exporter.

MalloZup avatar MalloZup commented on July 19, 2024

ok but on highlevel point this 2 check what they would provide? if we can't execute the binary (because of lack of findings or is not exec) we have an IF which check the error , and an error is throwed.

Ok right that's true, I remember we don't check everytime the error now for other reasons.. valid point.

from ha_cluster_exporter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.