/go-tcputil

[MOVED] See github.com/lestrrat-go/tcputil

Primary LanguageGoMIT LicenseMIT

go-tcputil

Some Utilities To Help Your TCP-Related testing

WARNING

This repository has been moved to github.com/lestrrat-go/tcputil. This repository exists so that libraries pointing to this URL will keep functioning, but this repository will NOT be updated in the future. Please use the new import path.A

SYNOPSIS

  p, err := EmptyPort()
  if err != nil {
    log.Fatal(err)
  }

  cmd := exec.Command("memcached", "-p", fmt.Sprintf("%d", p))
  go cmd.Run()

  err = WaitLocalPort(p, 30 * time.Second)
  if err != nil {
    log.Fatal(err)
  }

  // Now do whatever with memcached!

  cmd.Process.Kill()

For a higher level wrapper for testing network servers on random local ports, see go-tcptest

API docs: http://godoc.org/github.com/lestrrat/go-tcputil