Connect to MongoDB Database in Golang

package main

import (
	"fmt"
	_ "github.com/go-sql-driver/mysql"
	"gopkg.in/mgo.v2"
)

func connectDB() (*mgo.Database, error) {
	host := "mongodb://localhost:27017"
	dbName := "nilpointer"
	session, err := mgo.Dial(host)
	if err != nil {
		return nil, err
	}
	db := session.DB(dbName)
	return db, nil
}

func main() {
	_, err := connectDB()
	if err != nil {
		fmt.Println(err)
	} else {
		fmt.Println("Success")
	}
}
Success