Part 1: Introduction and Installation of Golang
This is our first tutorial in our series(Building REST API with Go).
All the code in this tutorial series will be hosted on github which will save you a lot of typing.However make sure you understand the concept before copy pasting any code.
What is golang ?
Golang (Go) is a statically and compiled language created by google.
Go is mostly used to develop highly scalable and fast web apps.
Benefits of using go for your rest api
There are so many programming languages to choose from when you want to make a rest api.Python(flask),node or even java. However go has some benefits which makes it a good choice whenever you are making a rest api.
Here are some of the benefits of using go:
- Quick compilation and execution speed.
- its very easy and fast to learn -go has a very simple syntax.This makes it very easy to learn.
- Lightweight goroutines that support concurrency.
- Extensive and very well documented built-in libraries.
What are we building ?
In the course of this series we are going to build a food delivery app.Our api will allow a customer to request for food to be delivered to her address. Each tutorial will be building upon the previous tutorials thus its advisable to read the tutorial in a sequential order.
Prerequisites
We are going to use the following to create our api
- Go
- Postgres-this will be our database for us to store our data.Make sure you have postgres installed
- Gorm -Gorm is a fantastic orm that will help us save and query data from our database easily.
- chi router - is a lightweight, idiomatic and composable router for building Go HTTP services.
- Postman -we will be using postman to make request to our api.Make sure you install postman
Each of this will be discussed in more details as we go on.
Installation of golang
Golang support all the three platform (mac os,linux and windows).
MacOS package installer
Download the package file, open it, and follow the prompts to install the Go tools. The package installs the Go distribution to /usr/local/go.
The package should put the /usr/local/go/bin directory in your PATH environment variable. You may need to restart any open Terminal sessions for the change to take effect.
Windows
Download the MSI installer. Double tap to start the installation and follow the prompts. This will install Golang in location c:\Go and will also add the directory c:\Go\bin to your path environment variable.
Linux
Download the tar file and unzip it to /usr/local.
Add /usr/local/go/bin to the PATH environment variable. This should install go in linux.
Hurray !! You have successfully installed golang in on your computer.In the next tutorial Part 2:Building A Hello,world Rest Api Endpoint In Go we are going to setup our go workspace and write our first basic go rest api.
Conclusion
You are about to start the most amazing journey.Make sure you provide some valuable feedback which will help me provide the best content.