Go Microservice Part I - Overview
By ski11up.com
MVC has a distinct role in web application development. It gives you a clean design and practical approach in designing and developing customer-facing software applications that takes input or set of inputs from the user and present the solution or the response to the user.
Let’s develop a web application using mvc
design pattern in Go
with the help of http
, Viper
, and Mux
packages.
App
We will develop a contact application that will retrieve contact details based on the input id
.

App
contains the routing details that is which controller function to call based on user request.
Application Configuration contains all the configuration details like Server PORT
, Data Base
connection details, etc. In our application, we have used it to store the PORT
number.
Controller
takes care of taking the user request, validates the input parameters, and sending it to the required Service
and rely on the Service
to process the user request. Once the data is processed Controller
receives the data from the Service
and send it the specified View
to present to the user.
Contact Service
process the contact detail information from the Model
and send it back to the Controller
. In the real world, it will call the DAO
Data Access Layer and process the data before sending it to the Controller
. Domain
will connect with the Data Base
for the required information and send it back to the Service
.
Model
or Domain
has details about the structure of the model object. Service(s)
communicate with DAO
to get the Model Data
.
Views
are usually represented by HTML
but in our application, we will just through the response using the Response
object.
Project Structure
We will be having the below folder structure for our contacts application.

main.go
contains the start app function.
app.go
contains the application routing and config mechanism as well for sending a request to the Controller
.
config.yml
has the application config.
config/
contains the code which will read the configuration from config.yml
and send it the application.
controllers/
has the Controller
code.
services/
has the actual Business Logic.
domain/
has the Model
object as well as DAO
for accessing the Database.
App
Let’s start with writing the application in parts in further posts.
Next
Go to Go MVC Part II to get started with the application configuration.