Skip to content

Instantly share code, notes, and snippets.

@kjk kjk/main.go
Created Nov 27, 2019

What would you like to do?
package main
import (
func main() {
// :show start
var stdout, stderr bytes.Buffer
cmd.Stdout = &stdout
cmd.Stderr = &stderr
err := cmd.Start()
if err != nil {
log.Fatalf("cmd.Start() failed with '%s'\n", err)
err = cmd.Wait()
if err != nil {
log.Fatalf("cmd.Wait() failed with '%s'\n", err)
out := append(stdout.Bytes(), stderr.Bytes()...)
fmt.Printf("Output:\n%s\n", string(out))
// :show end
You can’t perform that action at this time.