MCPcopy
hub / github.com/wavetermdev/waveterm / CopyToChannel

Function CopyToChannel

pkg/util/utilfn/utilfn.go:663–680  ·  view source on GitHub ↗

does *not* close outputCh on EOF or error

(outputCh chan<- []byte, reader io.Reader)

Source from the content-addressed store, hash-verified

661
662// does *not* close outputCh on EOF or error
663func CopyToChannel(outputCh chan<- []byte, reader io.Reader) error {
664 buf := make([]byte, 4096)
665 for {
666 n, err := reader.Read(buf)
667 if n > 0 {
668 // copy so client can use []byte without it being overwritten
669 bufCopy := make([]byte, n)
670 copy(bufCopy, buf[:n])
671 outputCh <- bufCopy
672 }
673 if err == io.EOF {
674 return nil
675 }
676 if err != nil {
677 return err
678 }
679 }
680}
681
682func GetCmdExitCode(cmd *exec.Cmd, err error) int {
683 if cmd == nil || cmd.ProcessState == nil {

Callers

nothing calls this directly

Calls 1

ReadMethod · 0.45

Tested by

no test coverage detected