Why does chan not deadlock in goroution?

package main
func main() {
    ch1 := make(chan int)
    go pump(ch1) // pump hangs
}
func pump(ch chan int) {
    ch <- 1
    ch <- 2
}

Why is it that there is nothing wrong with writing a corruption? Blocking the main process will deadlock

Mar.18,2021

deadlocks occur when all processes or threads are waiting for the resource to be released and the resource cannot be released.

here main finishes running without waiting for other goroutine, so no data flows into ch, and a total of main, is executed without blocking, so there is no deadlock. Change the code to:

package main

import "sync"

func main() {
    ch1 := make(chan int)

    var wg sync.WaitGroup
    wg.Add(1)
    go func() {
        ch1 <- 1
        wg.Done()
    }()

    wg.Wait()
    // <-ch1
}

deadlock occurs

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-1b366dd-2c017.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-1b366dd-2c017.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?