Skip to main content

Create MVC Pattern Using Echo Framework #GolangDev

pixabay.com

Hi, Back again. today I am gonna share about Go Language, yes it is a new programming language that really fast growing this day, so many startup using it, especially in indonesia, there is a Gojek, Dana, Tiket and many more. Go Lang is a programming language found by google engineer, this language is a multi paradigm language, you could use it as functional programming or treat it like an OOP bases.

Echo is an framework that use Golang as a main language, to use a fast and reliable backend/web apps, as you know Golang has a really fast performance than other language, one of the reason is because its compiled not interpreted, so the Echo claim that its 10x faster. insane right ? Actually I didn't test the performance yet, but yeah for newbie like me in golang its not the main thing that you must understand, so the thing that we should know is how we actually can do with Golang. 

I am person with MVC bases, before jump to golang, I have experience with Laravel, you know its typically MVC pattern bases, so to make me comfortable with new environment, I try to treat Golang to be a MVC bases to make a web apps. Hence Golang could do the seem thing without overwhelming to built as MVC.

Firstly install the Echo Framework using go get command, look at the documentation here.

I am using Echo because this framework is already present a router, controller, view unfortunately not the model, so if you need a models, I recomend you to use Gorm. Gorm is a package to manage a model and migration, you could define table and relation in one file model, just like a ORM do. if you dont know ORM, maybe this article will help you. another best thing is Gorm could be your migration too, so you could define a table and column name in the model, and apply the migration from the seem file. it's really good approach and applied DRY principal.

If you already have gorm installed, now you could create fundamental MVC folder structure to grouping the Models, Controller, and Views files.

Because I am people who really like the laravel structure folder, so I put any folder from laravel that I think it might be required. then the structure just link this.




If you know Laravel or Ruby on Rails, you might be familiar.

see the complete code here. Happy coding ^_^

Popular posts from this blog

Automatic API Documentation Swagger in Golang #GolangDev

pixabay.com In this article, I'll explain how to generate an API blueprint instantly using SwagGo in Golang. API blueprint is a document that contains a bunch of API endpoints, its slickly same as documentation but less description, it's allow another programmer to read and see all the available endpoint and try it out with sandbox feature. Swagger is one of the most used API blueprints right now, it's available in free but limited usage. if you wanna use the free credit, you need to understand YAML notation, you can read the example notation in swagger official documentation. but again, it's really hard and takes an expensive time to arranges all the notation to achieve a good API blueprint. fortunately, there are tools in Golang that allow us to generate the YAML notation and automatically generate the blueprint page with only using markup notation, and it's FREE unlimited for self-host, insane right? SwagGo tools are available here , the documentation is very cl...

OpenVPN Alternatif Solusi Menanggulangi Blokir dari KOMINFO

Sejak akhir juli 2022 kemaren indonesia di gegerkan dengan tindakan kominfo atas diblokirnya banyak platform digital karna tidak mendaftar PSE, terutama paypal dan plaform game (steam, epic game dll). keputusan ini semakin membuat netizen geram dikarenakan platform judi online malah disetujui untuk beroperasi karna sudah daftar PSE. Jujur menurut saya memang keputusan ini sejak awal saya dengar sudah mengada-ada karna sangat aneh memblokir semua platform digital yang jumlahnya tidak terhitung banyaknya dan hanya membolehkan akses platform yang sudah mendaftar yang jumlahnya hanya ratusan.  saya sebagai developer juga merasa aneh banget ini kebijakan apalagi platform development juga banyak yang di blacklist oleh kominfo seperti, github, gitlab, bitbucket, even website CDN pun di blacklist. astaga wkwkwk. anyway terlepas dari kebijakan konyol ini, saya mau berbagi tips cara agar tetep bisa mengakses semua platform tersebut tanpa ada halangan, yaitu dengan menggunakan VPN. banyak ban...

5 Backend Framework Terkenal dari Berbagai Bahasa Pemrograman

5 Backend framework yang terkenal dari berbagai bahasa pemrograman, banyak sekali framework baru bermunculan tetapi apakah semua bagus atau baik untuk diterapkan. berikut 5 framework yang bisa kamu coba untuk jadi pilihan projectmu: 1. Laravel Laravel adalah framework dari bahasa pemrograman PHP yang sangat terkenal hari ini, daripada framework php lain, laravel memberikan fitur lebih komplit untuk membangun modern website. laravel sering dipakai untuk website system internal dan website institusi. 2. Springboot Springboot adalah framework dari Java yang menjadi andalan untuk membuat system finance dan enterprise, springboot dipakai banyak aplikasi enterprise karna kapabilitasnya dalam support kebutuhan enterprise, dengan disupport oracle, springboot mjd nomer satu dikelasnya 3. Phoenix Phoenix adalah framework dari Elixir, framework ini memiliki speciality di bidang distributed and realtime system seperti chat platform. elixir sendiri adalah bahasa pemrograman berbasis erlang, sedang...