execing-processes
Exec’ing processes
原文:https://gobyexample.com/execing-processes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
| // Note:
// This code is from https://gobyexample.com.
package main
import (
"os"
"os/exec"
"syscall"
)
func main() {
binary, lookErr := exec.LookPath("ls")
if lookErr != nil {
panic(lookErr)
}
args := []string{"ls", "-a", "-l", "-h"}
env := os.Environ()
execErr := syscall.Exec(binary, args, env)
if execErr != nil {
panic(execErr)
}
}
|