I want to execute Binary Files inside GoLang Program.
Here is my code:
package main
import (
"fmt"
"os/exec"
)
func main() {
output, _ := exec.Command("/home/user/Golang/bin/hello").Output()
fmt.Println(output)
}
But I get the output as: []
Thanks in advance.
I can get the output.
package main
import (
"fmt"
"os/exec"
)
func main() {
output, err := exec.Command("/Users/duguying/gopath/bin/test").Output()
if err!=nil {
fmt.Println(err.Error())
}
fmt.Println(string(output))
}
check you binary file first or binary filepath is correcting. try to print out your error message.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With