Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllAddresses ¶
func GetFreePort ¶
GetFreePort returns a single available port by asking the operating system to pick one for us. Luckily ports are not re-used so after asking for a port number, we attempt to create a tcp listener.
Essentially the same code as https://github.com/phayes/freeport but we bind to 0.0.0.0 to ensure the port is free on all interfaces, and not just localhost.GetFreePort Ports must be unique for an address, not an entire system and so checking just localhost is not enough.
func GetFreePorts ¶
GetFreePorts returns an array available ports by asking the operating system to pick one for us.
Essentially the same code as https://github.com/phayes/freeport apart from the caveats described in GetFreePort.
func GetNetworkAddress ¶
func GetNetworkAddress(requested AddressType, getAddresses AddressLister) ([]string, error)
GetNetworkAddress returns a list of network addresses of the requested type, sourcing the addresses from the provided AddressLister. It is expected that network.AddAddresses() will be the default address lister. The result is a list of strings representing the network addresses in the order they were returned by the AddressLister.
Types ¶
type AddressLister ¶
type AddressType ¶
type AddressType int
const ( PrivateAddress AddressType = iota PublicAddress LoopbackAddress LinkLocal Multicast Any )
func AddressTypeFromString ¶
func AddressTypeFromString(t string) (AddressType, bool)
func (AddressType) String ¶
func (a AddressType) String() string