Skip to content

Instantly share code, notes, and snippets.

@jinwoo1225
Created October 28, 2021 06:31
Show Gist options
  • Save jinwoo1225/fa6f19375543ee02a2d9365bd9c9b4a0 to your computer and use it in GitHub Desktop.
Save jinwoo1225/fa6f19375543ee02a2d9365bd9c9b4a0 to your computer and use it in GitHub Desktop.
MongoDB integration
// https://www.mongodb.com/blog/post/quick-start-golang-mongodb-starting-and-setup
func main() {
client, err := mongo.NewClient(options.Client().ApplyURI("<ATLAS_URI_HERE>"))
if err != nil {
log.Fatal(err)
}
ctx, _ := context.WithTimeout(context.Background(), 10*time.Second)
err = client.Connect(ctx)
if err != nil {
log.Fatal(err)
}
defer client.Disconnect(ctx)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment