Once we run the program, the HTTP server will start locally listening on port 8080.
Opening http://localhost:8080 in a browser will display Hello World! from the server with the Content-Encoding response header value gzip, as shown in the following screenshot:
Let’s understand what each line in the program means:
- package main: This defines the package name of the program.
- import ( "io" "net/http" "github.com/gorilla/handlers" ): This is a preprocessor command that tells the Go compiler to include all files from io, net/http, and the github.com/gorilla/handlers package.
- const ( CONN_HOST = "localhost" CONN_PORT = ...