Created
October 28, 2021 06:31
-
-
Save jinwoo1225/fa6f19375543ee02a2d9365bd9c9b4a0 to your computer and use it in GitHub Desktop.
MongoDB integration
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
// 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