mirror of
https://github.com/jefferyjob/go-easy-utils.git
synced 2025-10-05 15:06:50 +08:00
16 lines
287 B
Go
16 lines
287 B
Go
package validx
|
|
|
|
import "net"
|
|
|
|
// IsIPv4 是否为ipv4地址
|
|
func IsIPv4(input string) bool {
|
|
ip := net.ParseIP(input)
|
|
return ip != nil && ip.To4() != nil
|
|
}
|
|
|
|
// IsIPv6 是否为ipv6地址
|
|
func IsIPv6(input string) bool {
|
|
ip := net.ParseIP(input)
|
|
return ip != nil && ip.To4() == nil
|
|
}
|