refactor: move reader close fn inside main scope

main
sudo pacman -Syu 2022-07-23 23:16:11 +07:00
parent 9bf002a166
commit 31724133f1
No known key found for this signature in database
GPG Key ID: D6CB5C6C567C47B0
1 changed files with 4 additions and 6 deletions

10
main.go
View File

@ -29,9 +29,11 @@ func runGoTest() int {
// Output pipe and error pipe
outReader, outWriter := io.Pipe()
defer outReader.Close()
defer outWriter.Close()
errReader, errWriter := io.Pipe()
defer errReader.Close()
defer errWriter.Close()
cmd.Stdout = outWriter
@ -47,9 +49,7 @@ func runGoTest() int {
return 0
}
func colorOutputReader(reader io.ReadCloser) {
defer reader.Close()
func colorOutputReader(reader io.Reader) {
scanner := bufio.NewScanner(reader)
for scanner.Scan() {
@ -82,9 +82,7 @@ func colorOutputReader(reader io.ReadCloser) {
}
}
func colorErrorReader(reader io.ReadCloser) {
defer reader.Close()
func colorErrorReader(reader io.Reader) {
scanner := bufio.NewScanner(reader)
for scanner.Scan() {