R
R
Roman Rakzin2016-05-29 14:20:46
go
Roman Rakzin, 2016-05-29 14:20:46

How to run another application in golang?

There are 2 applications.
How to just run file2.exe from file1.exe ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anatoly, 2016-05-29
@TwoRS

https://golang.org/pkg/os/exec/

package main

import (
  "bytes"
  "fmt"
  "os/exec"
)

func main() {
  cmd := exec.Command("dir")
  var buf bytes.Buffer
  cmd.Stdout = &buf
  err := cmd.Start()
  if err != nil {
    fmt.Printf("error: %v\n", err)
  }
  err = cmd.Wait()

  fmt.Printf("Command finished with error: %v\n", err)
  fmt.Printf("Command finished with output: %v\n", buf.String())
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question