Ejemplo n.º 1
0
func PostalCodesRecord(countryCode string) ([]string, error) {
	db, err := postalcodes.GetDb(countryCode)
	if err != nil {
		return nil, err
	}
	line := rand.Intn(len(db))
	return db[line], nil
}
Ejemplo n.º 2
0
func Address(countryCode string) (string, error) {
	db, err := postalcodes.GetDb(countryCode)
	if err != nil {
		return "", err
	}
	line := rand.Intn(len(db))
	return db[line][postalcodes.PLACE_NAME], nil
}
Ejemplo n.º 3
0
func AddressGen(countryCode string) (<-chan string, error) {
	log.Debug("Loading address database")
	db, err := postalcodes.GetDb(countryCode)
	log.Debug("Database is loaded!")
	if err != nil {
		return nil, err
	}
	c := make(chan string)
	go func() {
		for {
			line := rand.Intn(len(db))
			c <- db[line][postalcodes.PLACE_NAME]
		}
	}()
	return c, nil
}