datasource/mongo/mongo.go
func NewMongo(filename string, environment string) (*Mongo, error) {
	ctx := context.Background()
	cnf, err := GetMongo(filename, environment)
	if err != nil {
		return nil, err
	}
	var uri string
	if len(cnf.Username) > 0 && len(cnf.Password) > 0 {
		uri = fmt.Sprintf(`mongodb://%s:%s@%s:%d/%s`,
			cnf.Username,
			cnf.Password,
			cnf.Host,
			cnf.Port,
			cnf.Database,
		)
	} else {
		uri = fmt.Sprintf(`mongodb://%s:%d/%s`,
			cnf.Host,
			cnf.Port,
			cnf.Database,
		)
	}
	client, err := mongo.NewClient(uri)
	if err != nil {
		log.Printf("L'URI du serveur MongoDB est incorrect: %s", uri)
		return nil, err
	}
	err = client.Connect(ctx)
	if err != nil {
		log.Print("Impossible d'utiliser ce context")
		return nil, err
	}

	db := client.Database(cnf.Database)

	err = client.Ping(ctx, nil)
	if err != nil {
		log.Printf("Impossible de contacter %v sur le port %d", cnf.Host, cnf.Port)
		return nil, err
	}
	return &Mongo{Client: client, Database: db, context: ctx}, nil
}
func NewMongo(filename string, environment string) (*Mongo, error) {
	ctx := context.Background()
	cnf, err := GetMongo(filename, environment)
	if err != nil {
		return nil, err
	}
	var uri string
	if len(cnf.Username) > 0 && len(cnf.Password) > 0 {
		uri = fmt.Sprintf(`mongodb://%s:%s@%s:%d/%s`,
			cnf.Username,
			cnf.Password,
			cnf.Host,
			cnf.Port,
			cnf.Database,
		)
	} else {
		uri = fmt.Sprintf(`mongodb://%s:%d/%s`,
			cnf.Host,
			cnf.Port,
			cnf.Database,
		)
	}
	client, err := mongo.NewClient(uri)
	if err != nil {
		log.Printf("L'URI du serveur MongoDB est incorrect: %s", uri)
		return nil, err
	}
	err = client.Connect(ctx)
	if err != nil {
		log.Print("Impossible d'utiliser ce context")
		return nil, err
	}

	db := client.Database(cnf.Database)

	err = client.Ping(ctx, nil)
	if err != nil {
		log.Printf("Impossible de contacter %v sur le port %d", cnf.Host, cnf.Port)
		return nil, err
	}
	return &Mongo{Client: client, Database: db, context: ctx}, nil
}
//NewMongo creates a newinstance of Mongo