Once we run the program, the TCP server will start locally listening on port 8080.
Let’s understand what each line in the program means:
- package main: This defines the package name of the program.
- import ( "log" "net"): This is a preprocessor command that tells the Go compiler to include all files from the log and net package.
- const ( CONN_HOST = "localhost" CONN_PORT = "8080" CONN_TYPE = "tcp" ): We declare constants in a Go program using the const keyword. Here, we declare three constants—one is CONN_HOST with a value of localhost, another one is CONN_PORT with a value as 8080, and lastly CONN_TYPE with a value as tcp.
Next, we declared the main() method from where the program execution begins. As this method does a lot ...