Documentation ¶
Overview ¶
Package portpicker provides an available TCP or UDP port to use in a service above port 1023. It does not guarentee that the port will remain available.
Get a TCP port to bind on all valid IPs for binding:
port, err := TCP() if err != nil { panic(err) }
Same, but panic if it can't be done:
port := Must(TCP)
Get a UDP port on IP 192.168.0.1 and the IPV6 localhost:
port := Must(UDP, IP(net.ParseIP("192.168.0.1"), Local6()))
Get a TCP port on an IPv4 localhost:
port := Must(TCP, Local4())
When binding to localhost, use "localhost:<port>", don't assume [::1]:<port> or 127.0.0.1:<port. If you want that, use option IP("127.0.0.1") instead.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Must ¶
Must is used to call either a passed TCP() or UDP() call and its options. If there is an error, it panics
Types ¶
Click to show internal directories.
Click to hide internal directories.