Once we run the program, an HTTP server will start locally listening on port 8080. Opening http://localhost:8080 in a browser will display Hello World! from the server, 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 ( "fmt" "log" "net/http" ): This is a preprocessor command that tells the Go compiler to include all files from fmt, log, and the net/http package.
- const ( CONN_HOST = "localhost" CONN_PORT = "8080" ): We declare constants in the Go program using the const keyword. Here we declared two ...