示例#1
0
文件: main.go 项目: enjoylife/sec
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)
	}
}
示例#2
0
文件: main.go 项目: enjoylife/sec
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
}