예제 #1
0
파일: address.go 프로젝트: kolach/loadtest
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
}
예제 #2
0
파일: address.go 프로젝트: kolach/loadtest
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
}
예제 #3
0
파일: address.go 프로젝트: kolach/loadtest
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
}