Skip to content
/ exec Public

Similar to os/exec but without waiting for child process

License

Notifications You must be signed in to change notification settings

MrMarble/exec

Repository files navigation

exec Package

Go Reference Go Report Card Tests

The exec package in Go is designed to run external commands. It is similar to the os/exec package, but provides a simpler interface and does not support streaming.

Main Features

  • The main difference between exec and os/exec is that the process does not wait for child processes to finish. This is useful for running long-running processes that are expected to run in the background.

Example

out, err := exec.Command("date").Output()
if err != nil {
  log.Fatal(err)
}
fmt.Printf("The date is %s\n", out)

This example runs the date command and logs any errors that occur.