Tutorial Golang REST API + Firebird Part 1

Golang and Firebird

Happy Tuesday to WFH Fighters, Hopefully on this occasion all of you are given health and kept away from the corona virus, why did I make this tutorial? Because I want to make the most of free time for the progress of our beloved country, haha ​​..
Yaa Kalii

First I use Firebird RDBMS sql driver for nakagami

You can see the documentation for installing nakagami in Golang

Second, create a Firebird Database

example database name is FIREBIRD SLEEP 5 and table is TABLE_SLEEPH5

CREATE TABLE TABLE_SLEEPH5 (
ID INTEGER NOT NULL PRIMARY KEY,
FIRST_NAME VARCHAR(255),
LAST_NAME VARCHAR(255)
);
/* Autoincrement for field (ID) */
CREATE GENERATOR GEN_TABLE_SLEEPH5_ID;

Third create the Golang structure

Following is a simple Golang structure in my version

The Fourth Is We Begin Ngoding

Step -1 Start by writing some code in the config directory with the config.go file

Step -2 Next we create a stuct in the stuct directory

First you can create file name StructData.go

package _structtype StructData struct {
Id int64 `json:”id”`
FirstName string `json:”first_name”`
LastName string `json:”last_name”`
}

second you can create file name ResponseData.go

package _structtype ResponseData struct {
Status int64 `json:”status”`
Message string `json:”message”`
Data interface{} `json:”data”`
}

Step -3 Next we can Create Model in the directory models and you create file name ModelData.go

Step -4 Next we can Create API in the directory apis and you create file name ApisData.go

Step -5 Next we make a Router with the name main.go

Step -6 RESULT

Run Firebird at this stage using the firebird maestro tool with the following data:

And Result..

Okay that’s what I can give in this part 1 tutorial, the next meeting will discuss usage body, method post, function insert, update and delete.

Repo : https://github.com/kilerz/TutorialGoRestApi-Firebird

Note: Kalau ada waktu luang ya guys (haha..)