net

package
v1.1.5 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect(protoAddr string) (net.Conn, error)

Connect dials the given address and returns a net.Conn. The protoAddr argument should be prefixed with the protocol, eg. "tcp://127.0.0.1:8080" or "unix:///tmp/test.sock"

func GetFreePort

func GetFreePort() (int, error)

GetFreePort gets a free port from the operating system. Ripped from https://github.com/phayes/freeport. BSD-licensed.

func HttpGet

func HttpGet(url string, timeout time.Duration) (*http.Response, error)

HttpGet sends a GET request to the specified url with timeout and return the response.

func HttpRequest

func HttpRequest(request *http.Request, timeout time.Duration) (*http.Response, error)

HttpRequest sends the specified HTTP requests with timeout and return the response. For stability and security reason, we need to be available request timeouts, so http.Client{} and http.Get() are overridden with functions that rely on this function.

func ProtocolAndAddress

func ProtocolAndAddress(listenAddr string) (string, string)

ProtocolAndAddress splits an address into the protocol and address components. For instance, "tcp://127.0.0.1:8080" will be split into "tcp" and "127.0.0.1:8080". If the address has no protocol prefix, the default is "tcp".

Types

This section is empty.

Jump to

Keyboard shortcuts

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