port_test.go 358 B

123456789101112131415161718
  1. package port
  2. import (
  3. "fmt"
  4. "testing"
  5. )
  6. func TestPortAvailable(t *testing.T) {
  7. // fmt.Println(PortAvailable())
  8. //fmt.Println(IsPortAvailable(6881,"tcp"))
  9. p, _ := GetAvailablePort("udp")
  10. fmt.Println("udp", p)
  11. fmt.Println(IsPortAvailable(p, "udp"))
  12. t1, _ := GetAvailablePort("tcp")
  13. fmt.Println("tcp", t1)
  14. fmt.Println(IsPortAvailable(t1, "tcp"))
  15. }