This question already has an answer here:
I'm looking at the tutorial offered in conjunction with the release of the official mongo-go-driver and the connection example uses a MongoDB server on localhost
// Set client options
clientOptions := options.Client().ApplyURI("mongodb://localhost:27017")
However, the new hosted MongoDB service Atlas requires username and password to login. The connection string takes the format
mongodb://[username:password@]host1[/[database][?options]]
but there is no Golang example in the driver examples for Atlas.
So I'm wondering, what is the best way to log into Atlas without hard coding a password into a source file that will be posted on Github?
</div>