The Go net/http package exposes a flexible http.Client structure for working with HTTP APIs. This structure has separate transport functionality and makes it relatively simple to short-circuit requests, modify headers for each client operation, and handle any REST operations. Creating clients is a very common operation, and this recipe will start with the basics of working and creating an http.Client object.
How to do it...
These steps cover writing and running of your application:
- From your Terminal or console application, create a new directory called ~/projects/go-programming-cookbook/chapter7/client, and navigate to this directory.
- Run the following command:
$ go mod init github.com/PacktPublishing/Go-Programming-Cookbook-Second-Edition/chapter7/client
You should see a file calledgo.mod containing the following:
module github...