// BuildConnectionStringForMongoDB builds a connection string from env vars or returns an error if one of them is missing.
BuildConnectionStringForMongoDB builds a connection string from env vars or returns an error if one of them is missing.
// BuildConnectionStringForMongoDB builds a connection string from env vars or returns an error if one of them is missing .
func BuildConnectionStringForMongoDB() (string, error) {
	mongoUser := os.Getenv("MONGO_USERNAME")
	if mongoUser == "" {
		return "", errors.New("no MongoDB username specified")
	}
	mongoPassword := os.Getenv("MONGO_PASSWORD")
	if mongoPassword == "" {
		return "", errors.New("no MongoDB password provided")
	}
	mongoContainer := os.Getenv("MONGO_CONTAINER_NAME")
	if mongoContainer == "" {
		return "", errors.New("no MongoDB container name provided")
	}
	mongoPort := os.Getenv("MONGO_PORT")
	if mongoPort == "" {
		return "", errors.New("no MongoDB port provided")
	}
	connStr := fmt.Sprintf("mongodb://%s:%s@%s:%s", mongoUser, mongoPassword, mongoContainer, mongoPort)
	return connStr, nil
}
func BuildConnectionStringForMongoDB ( ) ( string , error ) { mongoUser := os . Getenv ( " " ) if mongoUser == " " { return " " , errors . New ( " " ) } mongoPassword := os . Getenv ( " " ) if mongoPassword == " " { return " " , errors . New ( " " ) } mongoContainer := os . Getenv ( " " ) if mongoContainer == " " { return " " , errors . New ( " " ) } mongoPort := os . Getenv ( " " ) if mongoPort == " " { return " " , errors . New ( " " ) } connStr := fmt . Sprintf ( " " , mongoUser , mongoPassword , mongoContainer , mongoPort ) return connStr , nil }
BuildConnectionStringForMongoDB builds a connection string from env vars or returns an error if one of them is missing.
BuildConnectionStringForMongoDB builds a connection string from env vars or returns an error if one of them is missing .