Last active
November 7, 2017 07:48
-
-
Save wilk/fd2d48c3d17510d0f0ba3917f8eed66e to your computer and use it in GitHub Desktop.
Goxfer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"os" | |
"gopkg.in/mgo.v2" | |
) | |
var ( | |
DB_HOST = os.Getenv("DB_HOST") | |
DB_NAME = os.Getenv("DB_NAME") | |
DB_COLLECTION_NAME = os.Getenv("DB_COLLECTION_NAME") | |
) | |
func main() { | |
session, err := mgo.Dial(DB_HOST) | |
if err != nil { | |
panic(err) | |
} | |
defer session.Close() | |
session.SetMode(mgo.Monotonic, true) | |
collected := session.DB(DB_NAME).C(DB_COLLECTION_NAME) | |
fmt.Println("DB connected") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment