Skip to content

Closures and channel operations result in a bug #508

@aykevl

Description

@aykevl

The following doesn't produce the expected output:

package main

var strch = make(chan string)

func main() {
	strch := strch // comment this line to avoid the bug
	go func() {
		println("sending...")
		strch <- "hello"
		println("sent!")
	}()
	println(<-strch)
}

There appears to be some sort of interaction between closures and channel operations that goes wrong.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions