package main
import (
"bytes"
"fmt"
"os/exec"
)
func main() {
prc := exec.Command("ls", "-a")
out := bytes.NewBuffer([]byte{})
prc.Stdout = out
err := prc.Run()
if err != nil {
fmt.Println(err)
}
if prc.ProcessState.Success() {
fmt.Println("Process run successfully with output:\n")
fmt.Println(out.String())
}
}
2
package main
import (
"bytes"
"fmt"
"os/exec"
)
func main() {
prc := exec.Command("ls", "-a")
out := bytes.NewBuffer([]byte{})
prc.Stdout = out
err := prc.Start()
if err != nil {
fmt.Println(err)
}
prc.Wait()
if prc.ProcessState.Success() {
fmt.Println("Process run successfully with output:\n")
fmt.Println(out.String())
}
}
/*
.
..
.idea
b.go
go_web
*/