Documentation ¶
Overview ¶
Package gipv4 提供了用于处理 IPv4 地址的有用 API。
Index ¶
- func GetHostByName(hostname string) (string, error)
- func GetHostsByName(hostname string) ([]string, error)
- func GetIntranetIp() (ip string, err error)
- func GetIntranetIpArray() (ips []string, err error)
- func GetIpArray() (ips []string, err error)
- func GetMac() (mac string, err error)
- func GetMacArray() (macs []string, err error)
- func GetNameByAddr(ipAddress string) (string, error)
- func GetSegment(ip string) string
- func Ip2long(ip string) uint32
- func IsIntranet(ip string) bool
- func Long2ip(long uint32) string
- func MustGetIntranetIp() string
- func ParseAddress(address string) (string, int)
- func Validate(ip string) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetHostByName ¶
GetHostByName 返回给定互联网主机名对应的IPv4地址。
func GetHostsByName ¶
GetHostsByName 函数根据给定的互联网主机名返回对应的 IPv4 地址列表。
func GetIntranetIpArray ¶
GetIntranetIpArray 获取并返回当前机器的内网IP列表。
func GetNameByAddr ¶
GetNameByAddr 根据给定的IP地址返回相应的Internet主机名。
func GetSegment ¶
GetSegment 返回给定IP地址的段。例如:192.168.2.102 -> 192.168.2
func IsIntranet ¶
IsIntranet 检查并返回给定的IP是否为内网IP。
本地(Local):127.0.0.1 A类:10.0.0.0--10.255.255.255 B类:172.16.0.0--172.31.255.255 C类:192.168.0.0--192.168.255.255
func MustGetIntranetIp ¶
func MustGetIntranetIp() string
MustGetIntranetIp 的行为与 GetIntranetIp 相同,但当发生任何错误时,它会触发 panic。
func ParseAddress ¶
ParseAddress 将 `address` 解析为其 IP 地址和端口号。 例如:192.168.1.1:80 -> 192.168.1.1, 80
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.