How to use this connection in other go files MongoDB?


(Illud) #1

Export this connection and call it from other files.
im using go-bongo a ODM

func Conn(){
  config := &bongo.Config{
    ConnectionString: "mongodb://go:fake@ds117523.mlab.com:17542/golangfake",
    Database:         "golang",
    }
    connection, _ := bongo.Connect(config)
 }

call that function.

func main(){
    Conn.connection //something like this
}