How it works...

Once we run the program on an EC2 instance, the HTTP server will start locally listening on port 80.

Next, execute a GET request from the command line as:

$ curl -i -X GET http://ec2-172-31-34-99.compute-1.amazonaws.com:80/

This will give Hello World! as a response, which will give the following output:

HTTP/1.1 200 OKDate: Sat, 06 Jan 2018 10:59:38 GMTContent-Length: 12Content-Type: text/plain; charset=utf-8 Hello World!

Get Go Web Development Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.