Execing processes
Context
Section titled “Context”syscall.Exec replaces the current Go process with another program (no return). This is rarely used but available for advanced cases.
Example
Section titled “Example”Replace the current process with /bin/ls.
Code example
Section titled “Code example”package main
import ( "syscall")
func main() { binary := "/bin/ls" args := []string{"ls", "-l"} env := syscall.Environ()
err := syscall.Exec(binary, args, env) if err != nil { panic(err) }}Output (example)
Section titled “Output (example)”total 0-rw-r--r-- 1 user staff 0 Jan 1 12:00 file.txt