kola/coretest/helpers: use `DialTimeout` instead of self timeout
It's cleaner and eliminates the chance of our goroutine outliving the
function.
@@ -2,7 +2,6 @@ package coretest
import (
"bufio"
- "fmt"
"io/ioutil"
"net"
"os"
@@ -11,19 +10,9 @@ import (
)
func CheckPort(network, address string, timeout time.Duration) error {
- errc := make(chan error, 1)
- go func() {
- _, err := net.Dial(network, address)
- errc <- err
- }()
- select {
- case <-time.After(timeout):
- return fmt.Errorf("%s:%s timed out after %s seconds.",
- network, address, timeout)
- case err := <-errc:
+ _, err := net.DialTimeout(network, address, timeout)
return err
}
-}
type MountTable struct {
Device string
