netx

package module
v0.0.0-...-1750f3d Latest Latest
Warning

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

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

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).

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 TryAddPort

func TryAddPort(server string, port string) string

TryAddPort checks whether the server string already has a port (i.e., ends with ':<PORT>'. If it does, thn 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