Query JSON data using Golang (gojsonq package)

Most often developer needs to consume JSON data from other service and query over them. Querying JSON data is little time consuming. For the last few days I was working on a package for Golang to query JSON data easily. The idea and inspiration comes form PHP-JSONQ by Nahid Bin Azhar. Lets take a sample JSON data to start with: Now we are ready to query the data, lets see some examples ...

May 29, 2018 · 2 min · Saddam H

Let’s make a simple todo app with Go

Generally Go is perfect for building micro services, but it doesn’t mean that trivial MVC app are not easy to build. Go has built-in support for parsing html template, though we are not going to focus on that. First of all let’s write our go code for serving a html page and save it in a directory. In our case let’s call the directory todoapp and create a home.tpl file inside it. Paste the html in home.tpl, it doing some http call to our backend application. ...

November 24, 2017 · 5 min · Saddam H

An easy way to validate Go request

When building REST API or web applications using Go, an essential part is to validate the incoming request data. I have worked in some small and medium project in Golang, most of them are micro-services, providing restful api. I have used different way to validate incoming data. Lets start with particular one that I use frequently. For validating application/json or text/plain request, first I build a struct type of that particular request and add a validate method on the struct. Lets see an example: ...

November 22, 2017 · 2 min · Saddam H

Build RESTful API service in golang using gin-gonic framework

Today I’m going to build a simple API for todo application with the golang programming language. I’m going to use golang simplest/fastest framework gin-gonic and a beautiful ORM gorm for our database work. To install these packages go to your workspace $GOPATH/src and run these command below: $ go get gopkg.in/gin-gonic/gin.v1 $ go get -u github.com/jinzhu/gorm $ go get github.com/go-sql-driver/mysql In generic crud application we need the API’s as follows: ...

November 12, 2017 · 5 min · Saddam H