Go语言:向生成的进程发送数据时,Wait()不返回

I need to send several MB to a spawned Go process. I followed the directions at https://gobyexample.com/spawning-processes, but my data is too large to send that way. I thought I could chunk the data. Here is the code I ended up with:

doit := exec.Command("/bin/bash", "-c", cmd)    // cmd reads stdin
doit_stdin,_  := doit.StdinPipe()
doit_stdout,_ := doit.StdoutPipe()

doit.Start()

go func() {
  w := bufio.NewWriter(doit_stdin)
  for i := 0; i < nchunks; i++ {
    w.Write(input_data[chunk_begin[i]:chunk_begin[i+1]]) 
    w.Flush()
  }
  doit_stdin.Close()
}()

rc,_ := ioutil.ReadAll(doit_stdout)
doit.Wait()

Where input_data is []byte and chunk_begin is an array of break points computed elsewhere. Everything works just fine. cmd gets all the data sent to it, detects EOF, sends results back and exits. ReadAll gets all the info sent back from cmd. But do it.Wait() blocks. I cannot understand why doit.Wait is blocking.

Or if there is some other standard way of transferring larger amounts of data, that would be fine too. I do need to control the break points because the data has internal structure.

Any help would be greatly appreciated.