Advance Golang

Summary

If you are new comer of Golang, you can read about basic golang to get some knowledge about this programming language. And I hope you have some funny about it. In the fact that, to become a professional coder, basic golang is not enough, that is only base to learn about how to create a real program.

What is a real program?

In basic, program has only 3 parts

1. User interface

That is a screen which you can click button, type a text into textbox and that is work of frontend coder. They also create a program, but it only process on user interface, capture action of user and send to Processing Logic

2. Processing Logic

I like call this layer is API service. That is a program which run on online server machine, get input from User Interface and response a data to User Interface. Golang is strong in this layer.

Amazing, you run a service program which be never stoped, listen input data from a client, process data and response processed data. If not any client sends your program input, your program still wait for.

A program like that, we call API service. And protocol which often be used for is RESTful API. I will introduce to you later about it with a instruction.

3. Data storage

99,99% program need to save data of user into database. In real life, you will need to save excel file, document file, … or hard file. So final purpose of any program is storage data.

Example: when you go to facebook, it ask you fill a sign-up form to get accessing into facebook. Sign-up for what? That is facebook need to store data of yours and When you log-in, It check data and give you accessing. Or when you post something on facebook wall, it should store your post and you friend can see it.

Easy to understand

“User Interface —Input–> ProcessingLogic —Input–>Data Storage”

“User Interface <–Output— ProcessingLogic <–OK—Data Storage”

Implement a simple real program

Data storage

Here, I will show you instruction How to implement a data storage layer in golang easilyest

What is Database? Using MySQL?

Using struct like object mapping in golang with MySQL

Implement data access object to process struct with Mysql Table

Processing service

Here, I will show you How to implement Restful API service to get Input and response Output for any client with json data

Gin gonic, good framework for Restful API

Split code to many layer

Middleware in Gin gonic

Contact to Data storage by DAO(data access object)