Created
February 6, 2017 00:00
-
-
Save s-hiiragi/00f9efb0b35be536a2d2579f790d4cfc to your computer and use it in GitHub Desktop.
Goで外部コマンドを実行して標準出力を得るサンプル
This file contains hidden or 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" | |
"log" | |
"os/exec" | |
) | |
func main() { | |
out, err := exec.Command("ls", "-l").Output() | |
if err != nil { | |
log.Fatal(err) | |
} | |
fmt.Println(string(out)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment