Commit 102df4ab authored by Boris Mühmer's avatar Boris Mühmer
Browse files

transformed to for-loop

parent 4bb6dc8a
Loading
Loading
Loading
Loading
+25 −19
Original line number Diff line number Diff line
@@ -111,25 +111,31 @@ func (x *Expect) worker(started chan<- bool) {
	defer close(checkStream)

	var wg sync.WaitGroup
	wg.Add(2)
	go func() {
		defer wg.Done()
		process(
			stdout,
			startedOutStream,
			matchOutStream,
			stringStream,
			terminateOutStream, terminatedOutStream)
	}()
	go func() {

	for _, pa := range []struct {
		in               io.Reader
		startedStream    chan<- bool
		matchStream      <-chan Match
		stringStream     chan<- string
		terminateStream  <-chan bool
		terminatedStream chan<- bool
	}{
		{stdout, startedOutStream, matchOutStream, stringStream, terminateOutStream, terminatedOutStream},
		{stderr, startedErrStream, matchErrStream, stringStream, terminateErrStream, terminatedErrStream},
	} {
		wg.Add(1)
		go func(
			in io.Reader,
			startedStream chan<- bool,
			matchStream <-chan Match,
			stringStream chan<- string,
			terminateStream <-chan bool,
			terminatedStream chan<- bool,
		) {
			defer wg.Done()
		process(
			stderr,
			startedErrStream,
			matchErrStream,
			stringStream,
			terminateErrStream, terminatedErrStream)
	}()
			process(in, startedStream, matchStream, stringStream, terminateStream, terminatedStream)
		}(pa.in, pa.startedStream, pa.matchStream, pa.stringStream, pa.terminateStream, pa.terminatedStream)
	}

	<-startedOutStream
	<-startedErrStream