Skip to content

runtime: select should ignore closed channels #11344

Closed
@nigeltao

Description

@nigeltao

This program panics:

package main

import (
    "fmt"
)

func main() {
    c := make(chan int, 10)
    close(c)
    d := make(chan int, 10)
    for i := 0; i < 10; i++ {
        fmt.Println(i)
        select {
        case c <- 0:
        case d <- 0:
        }
    }
    fmt.Println("OK")
}

because c is still selectable even when closed. This seems consistent with the spec, but I think that the spec and the runtime should change.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions