[go-nuts] Re: idiomatic code to find, if executable exists in golang

2018-09-26 Thread Dave Cheney
My suggestion is, rather than seeing if an executable exists, then executing 
it. Just execute it and if there is an error just pass it back to the caller. 
The difference between I tried to run the program but it wasn’t found and I 
tried to run the program but it failed for some reason shouldn’t matter. 

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: idiomatic code to find, if executable exists in golang

2018-09-26 Thread Nilsocket


On Wednesday, September 26, 2018 at 1:16:51 PM UTC+5:30, Dave Cheney wrote:
>
> Are you able to modify the original question. Why do you need to know if a 
> binary exists? Presumably so you can execute it. If so then you can modify 
> the original request and make the problem more tractable. 

 
I don't get what you mean by,

> modify the original request and make the problem more tractable. 
>

Why I need to known, if an executable exists is,

I'm trying to write a program which reads a list of commands from file and 
execute, and the format I want is simple, so I fixed to something like this,

hello
   echo "hello world!"
   echo "hello represents two of us and the below two"
   ls
   temp

temp
   echo "temp here"
   echo "If hello is called, even I will be executed"

one can consider hello to be something like a variable, it can hold other 
variables and so on (can be deeply nested)...

According to the format, `temp` can either be a executable with no 
arguments or some-other variable.

I do known that this is mostly possible to do with shell script, I'm doing 
to this just for fun.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.