Iris Go Framework + MongoDB

Santosh Anand
Go Language
Published in
1 min readNov 2, 2017

In this tutorial we will connect Mongo DB with Iris Go Framework, I am using mgo to make a connection with Iris.

Iris is the fastest backend web framework for Go. It is faster than Node.js and .Net framework. Please take a look https://iris-go.com/ for the benchmark and more information.

MongoDB is a document datastore, it is storing data in JSON format. It is not storing data into table or row format.

I am assuming that you have already install Google Go, and Mongo DB. If you do not have installed Iris Framework then go to their site and check documentation.

In this tutorial, we’ll write a simple program to connect with MongoDB:

  • Simple server with Iris
  • Connect with MongoDB using mgo
  • Result

Simple server with Iris Framework

It is very simple and only three line code to create server.

Do not forget to go get -u github.com/kataras/iris

Simple Server with Iris Go Framework

Connect with MongoDB using mgo

First you have to install mgo using following line

go get gopkg.in/mgo.v2

Result

To run the above code type following code into terminal and hit enter to run the server.

go run example2.go

Open browser and type http://localhost:8080/car to see the result.

--

--