Golang os/exec.Cmd.Output() function example

package os

Golang os/exec.Cmd.Output() function usage example

 package main

 import (
  "fmt"
  "os/exec"
 )

 func main() {
  // Create an *exec.Cmd
  output, err := exec.Command("echo", "Hello World!").Output()

  if err != nil {
 panic(err)
  }

  fmt.Printf("Command output :  %s \n", output)

 }

Reference :

http://golang.org/pkg/os/exec/#Cmd.Output

Advertisement