How to connect from Go to the mongodb Docker authorization?

Good day!

There is code to Go in Docker container:
mc, err := mongo.Connect(ctx, options.Client().ApplyURI("mongodb://"+user+":"+password+"@"+host+":"+port+"/"+common.StoreName))
 if err != nil {
 return fmt.Errorf("Mongo connection error: %+v", err)
}

 err = mc.Ping(ctx, readpref.Primary())
 if err != nil {
 return fmt.Errorf("Mongo connection ping: %+v", err)
 }


Mongodb is in dacre container:
mongodb:
 container_name: mongodb
 image: mongo:latest
environment:
 MONGO_INITDB_ROOT_USERNAME: user
 MONGO_INITDB_ROOT_PASSWORD: password
 MONGO_INITDB_DATABASE: database
volumes:
 - './data:/data/db'


Get the error
Mongo connection ping: connection() : auth error: sasl conversation error: unable to authenticate using mechanism "SCRAM-SHA-1": (AuthenticationFailed) Authentication failed.
April 7th 20 at 10:55
0 answer

Find more questions by tags MongoDBGo