func initUrls(year, startMonth, endMonth int) { for month := startMonth; month <= endMonth; month++ { feedUrl := strings.Replace(BASE_URL, "{year}", strconv.Itoa(year), 1) feedUrl = strings.Replace(feedUrl, "{month}", helpers.LeftPad2Len(strconv.Itoa(month), "0", 2), 1) //urls.PushBack(feedUrl) urls = append(urls, feedUrl) } }
func genUrls(year, startMonth, endMonth int) <-chan string { out := make(chan string) go func() { for month := startMonth; month <= endMonth; month++ { feedUrl := strings.Replace(BASE_URL, "{year}", strconv.Itoa(year), 1) feedUrl = strings.Replace(feedUrl, "{month}", helpers.LeftPad2Len(strconv.Itoa(month), "0", 2), 1) out <- feedUrl } close(out) }() return out }