ip_test.go 549 B

1234567891011121314151617181920212223242526272829303132
  1. package ip_helper
  2. import (
  3. "fmt"
  4. "net"
  5. "testing"
  6. "go.uber.org/goleak"
  7. )
  8. func TestGetExternalIPV4(t *testing.T) {
  9. goleak.VerifyNone(t)
  10. ipv4 := make(chan string)
  11. go func() { ipv4 <- GetExternalIPV4() }()
  12. fmt.Println(<-ipv4)
  13. }
  14. func TestGetExternalIPV6(t *testing.T) {
  15. ipv6 := make(chan string)
  16. go func() { ipv6 <- GetExternalIPV6() }()
  17. fmt.Println(<-ipv6)
  18. }
  19. func TestGetLoclIp(t *testing.T) {
  20. fmt.Println(GetLoclIp())
  21. }
  22. func TestHasLocalIP(t *testing.T) {
  23. fmt.Println("dddd")
  24. fmt.Println(HasLocalIP(net.ParseIP("192.168.2.10")))
  25. }