func captureOutput(args []string, f func([]string) error) string {
	reader, writer, err := os.Pipe()
	if err != nil {
		panic(err)
	}
	stdout := os.Stdout
	stderr := os.Stderr
	defer func() {
		os.Stdout = stdout
		os.Stderr = stderr
		log.SetOutput(os.Stderr)
	}()
	os.Stdout = writer
	os.Stderr = writer
	log.SetOutput(writer)
	out := make(chan string)
	wg := new(sync.WaitGroup)
	wg.Add(1)
	go func() {
		var buf bytes.Buffer
		wg.Done()
		io.Copy(&buf, reader)
		out <- buf.String()
	}()
	wg.Wait()
	f(args)
	time.Sleep(100 * time.Millisecond)
	writer.Close()
	return <-out
}
// captureOutput captures all output to stdout and stderr after call f with args.
// Waits 100 millseconds and returns a string will all stdout and stderr output.
captureOutput captures all output to stdout and stderr after call f with args.
Waits 100 millseconds and returns a string will all stdout and stderr output.
// captureOutput captures all output to stdout and stderr after call f with args . // Waits 100 millseconds and returns a string will all stdout and stderr output .
func captureOutput(args []string, f func([]string) error) string {
	reader, writer, err := os.Pipe()
	if err != nil {
		panic(err)
	}
	stdout := os.Stdout
	stderr := os.Stderr
	defer func() {
		os.Stdout = stdout
		os.Stderr = stderr
		log.SetOutput(os.Stderr)
	}()
	os.Stdout = writer
	os.Stderr = writer
	log.SetOutput(writer)
	out := make(chan string)
	wg := new(sync.WaitGroup)
	wg.Add(1)
	go func() {
		var buf bytes.Buffer
		wg.Done()
		io.Copy(&buf, reader)
		out <- buf.String()
	}()
	wg.Wait()
	f(args)
	time.Sleep(100 * time.Millisecond)
	writer.Close()
	return <-out
}
func captureOutput ( args [ ] string , f func ( [ ] string ) error ) string { reader , writer , err := os . Pipe ( ) if err != nil { panic ( err ) } stdout := os . Stdout stderr := os . Stderr defer func ( ) { os . Stdout = stdout os . Stderr = stderr log . SetOutput ( os . Stderr ) } ( ) os . Stdout = writer os . Stderr = writer log . SetOutput ( writer ) out := make ( chan string ) wg := new ( sync . WaitGroup ) wg . Add ( 1 ) go func ( ) { var buf bytes . Buffer wg . Done ( ) io . Copy ( & buf , reader ) out <- buf . String ( ) } ( ) wg . Wait ( ) f ( args ) time . Sleep ( 100 * time . Millisecond ) writer . Close ( ) return <- out }
captureOutput captures all output to stdout and stderr after call f with args.
captureOutput captures all output to stdout and stderr after call f with args .