Why is this journey not blocked?

Program snippet is as follows:

runtime.GOMAXPROCS(runtime.NumCPU())
        //maxPage := getMaxPage()
        maxPage := 10
        if maxPage > 0 {
            jobs := make(chan int, maxPage)
            results := make(chan []map[string]string, maxPage)

            // jobsresults
            for w := 1; w <= runtime.NumCPU(); wPP {
                go worker(w, jobs, results)
            }
            db, err := mysqlUtil.CreateReadDb()
            if err != nil {
                log.Fatal("connect db err ", err)
                fmt.Println("connect db err ", err)
            }

            //
            for j := 1; j <= maxPage; jPP {
                jobs <- j
            }
            close(jobs)
            for data := range results {
                //
            }
            close(results)
            fmt.Println("all done...")
        }
The

woker function is as follows:

func worker(id int, jobs <-chan int, results chan<- []map[string]string) {
    for j := range jobs {
        url := host + "/type/1/" + strconv.Itoa(j) + ".html"
        fmt.Println()
        data := getData(url)
        fmt.Printf("worker %d finished job %d", id, j)
        fmt.Println()
        results <- data
    }
}

the problem now is that the program is in

for data := range results {
                //
            }

this place is blocked, the job is completed, the data after the job is completed are put into the result, and the operation of writing the library is completed above, so why is it blocked there and not executed further?

Apr.10,2021
The

range results operation does not continue until the pipe is closed. Otherwise it will be blocked all the time.


            for j := 1; j <= maxPage; jPP {
                data := <- results
                //
                fmt.Println(len(data))
            }
            close(results)
There is something wrong with the

program, so you can handle the result so that it won't block.


go func(){
        for data := range results {
            //
        }
    }()
    

goruntinegoruntine
resultsresultscloseclose
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1ea7a71-47c39.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1ea7a71-47c39.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?