How to build a basic server
The simplest HTTP server that we can create is a Hello World server. This is a server that returns a simple message stating Hello World
and will not do anything else. It is not very useful, but it is a starting point to see what default Go packages give us and is the basis for any other more complex server. The aim is to have a server that runs on a specific port on your machine’s local host and accepts any path under it. Accepting any path means that when you test the server with your browser, it will always return the Hello World
message and a status code of 200
. Of course, we could return any other message, but, for historical reasons, the simplest project you learn when you study programming is always some sort of software that returns a message stating Hello World
. In this case, we will see how this can be done and then visualized in a normal browser, before perhaps being put on the internet and shared with billions of users, although users may...