Created
March 30, 2020 05:24
-
-
Save makotom/e5828ec36f277b81a0eceaf70d0c5921 to your computer and use it in GitHub Desktop.
Go and "No-Go"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"bytes" | |
"os/exec" | |
) | |
func main() { | |
var out bytes.Buffer | |
userCmd := `dir "C:\Program Files"` | |
cmd := exec.Command("cmd.exe", "/c", userCmd) | |
cmd.Stdout = &out | |
cmd.Stderr = &out | |
_ = cmd.Run() | |
fmt.Printf("%s\n", out.String()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment