Skip to content

Instantly share code, notes, and snippets.

@s-hiiragi
Created February 6, 2017 00:00
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 s-hiiragi/00f9efb0b35be536a2d2579f790d4cfc to your computer and use it in GitHub Desktop.
Save s-hiiragi/00f9efb0b35be536a2d2579f790d4cfc to your computer and use it in GitHub Desktop.
Goで外部コマンドを実行して標準出力を得るサンプル
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