Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 2 of 2 for IsIPv6Address (0.26 sec)

  1. pkg/util/net/ip.go

    func IsValidIPAddress(ip string) bool {
    	ipa, err := netip.ParseAddr(ip)
    	if err != nil {
    		return false
    	}
    	return ipa.IsValid()
    }
    
    // IsIPv6Address returns if ip is IPv6.
    func IsIPv6Address(ip string) bool {
    	ipa, err := netip.ParseAddr(ip)
    	if err != nil {
    		return false
    	}
    	return ipa.Is6()
    }
    
    // IsIPv4Address returns if ip is IPv4.
    func IsIPv4Address(ip string) bool {
    Registered: Fri Jun 14 15:00:06 UTC 2024
    - Last Modified: Wed May 01 14:41:40 UTC 2024
    - 2.4K bytes
    - Viewed (0)
  2. pkg/util/net/ip_test.go

    			args: args{
    				ip: "2001:db8:::1",
    			},
    			want: false,
    		},
    	}
    	for _, tt := range tests {
    		t.Run(tt.name, func(t *testing.T) {
    			if got := IsIPv6Address(tt.args.ip); got != tt.want {
    				t.Errorf("IsIPv6Address() = %v, want %v", got, tt.want)
    			}
    		})
    	}
    }
    
    func TestIsIPv4Address(t *testing.T) {
    	type args struct {
    		ip string
    	}
    	tests := []struct {
    Registered: Fri Jun 14 15:00:06 UTC 2024
    - Last Modified: Wed May 01 14:41:40 UTC 2024
    - 8.7K bytes
    - Viewed (0)
Back to top