liveBook · Manning

Net/http package

The net/http package is Go’s standard-library package providing HTTP client and server implementations, requests, responses, and related functionality.

How 3 Manning books explain it

Learn Go with Pocket-Sized Projects

net/http is Go's standard-library package providing HTTP client and server implementations.

How it is used
Uses net/http to fetch exchange rates for a CLI and serve requests for a web service.
How deep it goes
Works through client timeouts, server startup, routing, handlers, status codes, and tests without detailing HTTP transport internals.
Examples
Uses an exchange-rate endpoint, a delayed test server, and a game-creation endpoint exercised with curl.
What you can do after
Build it from scratch: make a time-bounded HTTP call or serve and test a routed endpoint with net/http.

Read how Learn Go with Pocket-Sized Projects explains net/http package →

Go in Practice, Second Edition

net/http is Go's standard library package for HTTP clients and servers.

How it is used
Provides standard-library HTTP clients and servers, from simple requests and handlers to extensible web applications.
How deep it goes
Works through runnable GET and server examples, then describes request/client separation and configurable clients; server construction extends into routing and middleware.
Examples
Uses a localhost web server, a GET that reads a response body, a DELETE through the default client, and a timed custom client.
What you can do after
Build it from scratch as a small Go web server, and make GET or custom-client HTTP requests.

Read how Go in Practice, Second Edition explains net/http package →

Go by Example

The http package is Go's standard-library package providing HTTP client and server implementations and related types.

How it is used
Uses standard-library HTTP clients and servers to build responsive programs, services, request handlers, and tests.
How deep it goes
Explains client round trips and server handlers through APIs, execution flow, connection pooling, and response-writing order.
Examples
Uses concurrent request pipelines, NewRequest, NewRequestWithContext, Client.Do, status checks, handlers, and ResponseWriter.
What you can do after
Build it from scratch by sending HTTP requests, consuming responses, registering handlers, and serving clients.

Read how Go by Example explains net/http package →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.