Skip to content

Instantly share code, notes, and snippets.

@kgrvamsi
Created August 21, 2020 16:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kgrvamsi/36d8c6c8d4078173b44c5a019861ce2d to your computer and use it in GitHub Desktop.
Save kgrvamsi/36d8c6c8d4078173b44c5a019861ce2d to your computer and use it in GitHub Desktop.
Golang - Running Os level command
package main
import (
"fmt"
"log"
"os/exec"
)
func main() {
cmd := exec.Command("program") // or whatever the program is
cmd.Dir = "C:/usr/bin" // or whatever directory it's in
out, err := cmd.Output()
if err != nil {
log.Fatal(err)
} else {
fmt.Printf("%s", out);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment