cmd
                                
                                
                                
                                    cmd copied to clipboard
                            
                            
                            
                        have not Stdout when use Options
when i use Options
package main
import (
	"fmt"
	"github.com/go-cmd/cmd"
	"os/exec"
	"syscall"
)
func main() {
	opt := cmd.Options{
		Streaming: true,
		BeforeExec: []func(cmd *exec.Cmd){
			func(cmd *exec.Cmd) { cmd.SysProcAttr = &syscall.SysProcAttr{HideWindow: true} },
		},
	}
	newCmd := cmd.NewCmdOptions(opt, "cmd.exe", "/c", "whoami")
	//newCmd := cmd.NewCmd("cmd.exe", "/c", "whoami")
	gotStatus := <-newCmd.Start()
	fmt.Println(gotStatus.Stdout)
}
have no Stdout ===>output : [ ]
if not use Options it have a Stdout
package main
import (
	"fmt"
	"github.com/go-cmd/cmd"
)
func main() {
	//opt := cmd.Options{
	//	Streaming: true,
	//	BeforeExec: []func(cmd *exec.Cmd){
	//		func(cmd *exec.Cmd) { cmd.SysProcAttr = &syscall.SysProcAttr{HideWindow: true} },
	//	},
	//}
	//newCmd := cmd.NewCmdOptions(opt, "cmd.exe", "/c", "whoami")
	newCmd := cmd.NewCmd("cmd.exe", "/c", "whoami")
	gotStatus := <-newCmd.Start()
	fmt.Println(gotStatus.Stdout)
}
===>output : [desktop-123\nobody]
No obvious reason why this should be the case. This pkg is 100% tested and somewhat widely used, so such a fundament bug probably wouldn't have show up by now. Can you (or someone else) debug this to find the cause? I don't have a Windows machine so I cannot debug it.
I am getting the same issue
i don't get stdout or stderr if using options
I am on a mac
I can reproduce this. I'll take a look.
This is not a bug. What's happening is related to Streaming: true. From the docs for this option:
// If Streaming is true, Cmd.Stdout and Cmd.Stderr channels are created and // STDOUT and STDERR output lines are written them in real time. This is // faster and more efficient than polling Cmd.Status. The caller must read both // streaming channels, else lines are dropped silently.
So do this before running the cmd,
    go func() {
        for line := range newCmd.Stdout {
            fmt.Println(line)
        }
    }()
And it will print the (streaming) output.
Since this isn't a bug, will close issue. Please re-open if I'm wrong.