For when your goroutine caller needs to rejoin with the goroutine you could use a chan []byte to block until the command output string is ready. Channels are an important concurrent synchronization feature of Go that would keep all of your API response in one procedure.
Calling exec.Command and cmd.CombinedOutput like this makes sense to me. Matt On Friday, December 29, 2017 at 12:58:33 PM UTC-6, Marcelo Ribeiro wrote: > > Hello, > I'm coming now from the JAVA world, I want to hear your opinion on this. > > I'm doing a small API-RESTful, I'm using Echo to not get out of scratch. > > I have a third party program that to run it, I squeeze a command like this > "program.exe --verbose", with that, this program works on port 8080, it is > also an API-RESTful. I need to run this program from within my API > (Go-Echo), so whenever my API is run, that program will also run in > parallel, so I tried that and it worked, but I do not know if I'm on the > right track. > > go func() { > cmd := exec.Command("C:/go-workspace/ext-prog.exe", "--verbose") > out, err := cmd.CombinedOutput() > if err != nil { > rlog.Error(err) > } > rlog.Info(string(out)) > }() > > Could you tell me your opinion on the above code? > > Sorry for the weak English. > > Thank you. > Marcelo > -- 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.