I had a similar problem. The meaning that I found around the network, which should be included in the package "labix.org/v2/mgo", despite the fact that on the official website http://labix.org/mgo (while reading) it has more new and updated information that points to at least my gopkg.in/mgo.v2 package.
Hope this helps, as I got to the same steps as you, but then changed the link to the package. This code worked in my case:
package main import ( "fmt" "time" "gopkg.in/mgo.v2" ) //const MongoDb details const ( hosts = "ds026491.mongolab.com:26491" database = "messagingdb" username = "admin" password = "youPassword" collection = "messages" ) func main() { info := &mgo.DialInfo{ Addrs: []string{hosts}, Timeout: 60 * time.Second, Database: database, Username: username, Password: password, } session, err1 := mgo.DialWithInfo(info) if err1 != nil { panic(err1) } col := session.DB(database).C(collection) count, err2 := col.Count() if err2 != nil { panic(err2) } fmt.Println(fmt.Sprintf("Messages count: %d", count)) }
It is also on github
source share