host

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 27, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidHost 无效的主机名错误
	ErrInvalidHost = errors.New("无效的主机名")

	// ErrInvalidPort 无效的端口号错误
	ErrInvalidPort = errors.New("无效的端口号")
)

Functions

func BuildAddress

func BuildAddress(host string, port int) string

BuildAddress 根据主机名和端口号构建地址

func ExtractHostPort

func ExtractHostPort(addr string) (host string, port int, err error)

ExtractHostPort 从地址中提取主机名和端口号

func FindAvailablePort

func FindAvailablePort() (int, error)

FindAvailablePort 寻找可用端口

func GetHostname

func GetHostname() (string, error)

GetHostname 获取主机名

func GetLocalIP

func GetLocalIP() (string, error)

GetLocalIP 获取本地IP地址

func IsIPv4

func IsIPv4(addr string) bool

IsIPv4 判断是否为IPv4地址

func IsIPv6

func IsIPv6(addr string) bool

IsIPv6 判断是否为IPv6地址

func IsLocalHost

func IsLocalHost(host string) bool

IsLocalHost 判断是否为本地主机地址

func MustGetLocalIP

func MustGetLocalIP(fallback string) string

MustGetLocalIP 必须获取本地IP,如果获取失败则返回备用IP

func PortAvailable

func PortAvailable(port int) bool

PortAvailable 检查端口是否可用

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL