-
Type: Bug
-
Resolution: Works as Designed
-
Priority: Major - P3
-
None
-
Affects Version/s: 1.0.4
-
Component/s: Connections
-
None
-
Environment:go 1.12.x
github.com/gin-gonic/gin v1.4.0
github.com/golang/snappy v0.0.1 // indirect
github.com/sirupsen/logrus v1.4.2
github.com/spf13/viper v1.4.0
github.com/tidwall/pretty v1.0.0 // indirect
github.com/toorop/gin-logrus v0.0.0-20190701131413-6c374ad36b67
github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c // indirect
github.com/xdg/stringprep v1.0.0 // indirect
go.mongodb.org/mongo-driver v1.0.4
gopkg.in/src-d/go-git.v4 v4.13.1go 1.12.x github.com/gin-gonic/gin v1.4.0 github.com/golang/snappy v0.0.1 // indirect github.com/sirupsen/logrus v1.4.2 github.com/spf13/viper v1.4.0 github.com/tidwall/pretty v1.0.0 // indirect github.com/toorop/gin-logrus v0.0.0-20190701131413-6c374ad36b67 github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c // indirect github.com/xdg/stringprep v1.0.0 // indirect go.mongodb.org/mongo-driver v1.0.4 gopkg.in/src-d/go-git.v4 v4.13.1
I'm using JetBrains Goland IDE with next simple code to connection ping
// code placeholder ctx, cancel := context.WithTimeout(context.Background(), appConfig.DB.Timeout*time.Second) client, err := mongo.Connect(ctx, options.Client().ApplyURI(appConfig.DB.URI)) defer cancel() //Call the connect function of client //noinspection GoNilness err = client.Ping(ctx, readpref.Primary()) if err != nil { logrus.WithField("mongo", appConfig.DB.URI).Fatal("Mongo connection failed after timeout") } else { logrus.WithField("mongo", appConfig.DB.URI).Info("Mongo connected") appConfig.DB.Client = client }
method err = client.Ping(ctx, readpref.Primary()) show an error with message:
Can I fix myself in my code or it's deeper?