语言-重定向输出导致EOF后打开到命令exec的管道

I am trying to redirect the output of a process to one place, and then to open a pipe to the process , read its data and send the data to a predefined web socket connection --> but i get EOF.

For example :

myCmd := exec.Command("bash", "-c", "some command")

myCmd.Stdout = os.Stdout

myCmd.Stderr = os.Stderr

appOut, _ := lsCmd.StdoutPipe()

And then i am calling this go routine:

data := make([]byte, 1000)

for {

    for {

        n, err := appOut.Read(data)

        if err == nil && n > 0 {
            myConnection.WriteMessage(websocket.TextMessage, data[0:n])
        }

      if err != nil {
        log.Printf("App exited. err: %s, Error ", err)
       }

    }
}

Can someone tell me what i have done wrong ? I must mention that even if I change the order of the line (openning the pipe before the redirection it still happens)