Closed Ouroboros closed 5 years ago
Have the same issue. And there is the SO question: https://stackoverflow.com/questions/52256008/golang-cannot-recover-from-panic-mgo-dialwithinfo/52257061
Hi @Ouroboros,
Sorry for the delay!
Passing an empty URL is not necessarily an error, in this case it means mongo uses the default URL to connect (mongodb://localhost:27017
). From your tests, it seems the default URL behaviour is OS specific.
If you want to prevent empty URLs, you can just add a check on your end before passing it to mgo.
Making the driver flag it as an error would be a breaking change for people who are relying on that default URL to connect to mongo.
Hope this helps clarify,
Thanks, Esther
What version of MongoDB are you using (
mongod --version
)?What version of Go are you using (
go version
)?What operating system and processor architecture are you using (
go env
)?What did you do?
Write a piece of code to pass an empty string to
mgo.PraseURL()
:Note that this issue is OS-dependent. On Windows 10, the same code throws an error:
Possible solution:
You can check if string is empty in
func extractURL
: https://github.com/globalsign/mgo/blob/master/session.go#L790.Can you reproduce the issue on the latest
development
branch?Yes, it behaviours the same.