The HTTP package

Due to its importance and ubiquity, HTTP is one of a handful of protocols directly implemented in Go. The net/http package ( provides code to implement both HTTP clients and HTTP servers. This section explores the fundamentals of creating HTTP clients and servers using the net/http package. Later, we will return our attention back to building versions of our currency service using HTTP.

The http.Client type

The http.Client struct represents an HTTP client and is used to create HTTP requests and retrieve responses from a server. The following illustrates how to retrieve the text content of Beowulf from Project Gutenberg's website located at, using ...

Get Go: Design Patterns for Real-World Projects now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.