title: Get exit code - Go
body: <p>I'm using the package: os/exec <a href="http://golang.org/pkg/os/exec/">http://golang.org/pkg/os/exec/</a> to execute a command in the operating system but I don't seem to find the way to get the exit code. I can read the output though </p>
  
  <p>ie.</p>
  
  <pre><code>package main
  
  import(
      "os/exec"
      "bytes"
      "fmt"
      "log"
      )
  
  func main() {
      cmd := exec.Command("somecommand", "parameter")
      var out bytes.Buffer
      cmd.Stdout = &amp;out
      if err := cmd.Run() ; err != nil {
          //log.Fatal( cmd.ProcessState.Success() )
          log.Fatal( err )
      }
      fmt.Printf("%q\n", out.String() )
  }
  </code></pre>