netx

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 22, 2024 License: BSD-3-Clause Imports: 4 Imported by: 3

README

Go package that provides additional utilities for using the standard library's net package.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddrAsIP

func AddrAsIP(addr netip.Addr) net.IP

AddrAsIp converts a netip.Addr to a net.IP.

func HasPort

func HasPort(addr string) bool

HostPort returns whether addr includes a port number (i.e., is of the form HOST:PORT). It handles a corner-case in net.SplitHostPort which returns an empty port for addresses of the form "1.2.3.4:". For such addresses, HasPort returns false.

func IPAsAddr

func IPAsAddr(ip net.IP) netip.Addr

IPAsAddr converts a net.IP to a netip.Addr.

func IsIPv4

func IsIPv4(s string) bool

IsIPv4 returns true iff the addr string represents an IPv4 address.

func IsIPv6

func IsIPv6(s string) bool

IsIPv6 returns true iff the addr string represents an IPv6 address.

func TryJoinHostPort

func TryJoinHostPort(server string, port string) string

TryJoinHostPort checks whether the server string already has a port (i.e., ends with ':<PORT>'. If it does, then the function simply returns that string. If it does not, it returns the server string with the port appended.

Types

This section is empty.

Jump to

Keyboard shortcuts

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