netutil

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HostFromAddr

func HostFromAddr(addr string) (string, error)

HostFromAddr returns the host of "host:port", or the address itself when it has no port.

func SplitOptionalPort added in v0.3.0

func SplitOptionalPort(address string) (host, port string, hasPort bool, err error)

SplitOptionalPort splits "host:port" like net.SplitHostPort, and also accepts an address without a port, for which it returns the address itself as host and hasPort false. A bare bracketed IPv6 literal keeps its brackets. Any other malformed address returns net.SplitHostPort's error.

Types

type IPv6

type IPv6 struct {
	IP netip.Addr
}

func ToIPv6

func ToIPv6(addr netip.Addr) IPv6

ToIPv6 keys an address in the 16-byte form the packet counters use: an IPv4 address becomes its IPv4-mapped IPv6 form, and an IPv6 address, including its zone, is kept as it is.

func (IPv6) String

func (ip IPv6) String() string

Jump to

Keyboard shortcuts

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