netutil: fix goroutine error handling in test

Change from a done-channel to an error-channel in
TestLimitListenerError() to collect goroutine errors.

Change-Id: I7fb97a4ee18247123c686fd2b3e6f1bfe93de41e
Reviewed-on: https://go-review.googlesource.com/c/net/+/207465
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
diff --git a/netutil/listen_test.go b/netutil/listen_test.go
index e77e6f4..a9f596d 100644
--- a/netutil/listen_test.go
+++ b/netutil/listen_test.go
@@ -82,20 +82,25 @@
 
 // This used to hang.
 func TestLimitListenerError(t *testing.T) {
-	donec := make(chan bool, 1)
+	errCh := make(chan error, 1)
 	go func() {
+		defer close(errCh)
 		const n = 2
 		ll := LimitListener(errorListener{}, n)
 		for i := 0; i < n+1; i++ {
 			_, err := ll.Accept()
 			if err != errFake {
-				t.Fatalf("Accept error = %v; want errFake", err)
+				errCh <- fmt.Errorf("Accept error = %v; want errFake", err)
+				return
 			}
 		}
-		donec <- true
 	}()
+
 	select {
-	case <-donec:
+	case err := <-errCh:
+		if err != nil {
+			t.Fatalf("server: %v", err)
+		}
 	case <-time.After(timeout):
 		t.Fatal("timeout. deadlock?")
 	}