client

command
v1.81.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Client Example

The Client is useful when working with multiple hostnames.

See the simplest sendGetRequest() for GET and more advanced sendPostRequest() for a POST request.

The sendPostRequest() also shows:

  • Per-request timeout with DoTimeout()
  • Limit buffered response bodies with MaxResponseBodySize
  • Send a body as bytes slice with SetBodyRaw(). This is useful if you generated a request body. Otherwise, prefer SetBody() which copies it.
  • Parse JSON from response
  • Gracefully show error messages i.e. timeouts as warnings and other errors as a failures with detailed error messages.

How to build and run

Start a web server on localhost:8080 then execute:

make
./client

Client vs HostClient

Internally the Client creates a dedicated HostClient for each domain/IP address and cleans unused after period of time. So if you have a single heavily loaded API endpoint it's better to use HostClient. See an example in the examples/host_client

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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