(pipe io.ReadCloser, onReceive func([]byte), outboundChannel chan<- *ProcessResponse)
| 253 | } |
| 254 | |
| 255 | func scanErrorPipe(pipe io.ReadCloser, onReceive func([]byte), outboundChannel chan<- *ProcessResponse) (func(), *strings.Builder) { |
| 256 | remoteErrorMsg := &strings.Builder{} |
| 257 | return func() { |
| 258 | scanner := bufio.NewScanner(pipe) |
| 259 | scanner.Split(bufio.ScanLines) |
| 260 | for scanner.Scan() { |
| 261 | src := scanner.Bytes() |
| 262 | data := make([]byte, len(src)) |
| 263 | copy(data, src) |
| 264 | if onReceive != nil { |
| 265 | onReceive(data) |
| 266 | } |
| 267 | outboundChannel <- &ProcessResponse{stderr: data} |
| 268 | _, _ = remoteErrorMsg.Write(src) |
| 269 | _, _ = remoteErrorMsg.WriteString("\n") |
| 270 | } |
| 271 | }, remoteErrorMsg |
| 272 | } |
| 273 | |
| 274 | // CreateCmd wraps the args in "sh -c" for shell-level execution |
| 275 | func CreateCmd(args ...string) *exec.Cmd { |
no test coverage detected