Skip to content

proposal: spec: permit directional variants of named channel types #21953

Open
@robpike

Description

@robpike

Consider this program:

package main

import (
	"fmt"
)

type Foo chan string

func main() {
	c := make(Foo, 1)
	c <- "gotcha"
	fmt.Println(<-c)
}

All is well. Now try to declare a direction for a Foo:

package main

type Foo chan string

func main() {
	var x <-Foo
}

// or

func x(c <-Foo) { }

This doesn't parse, but it's reasonable to expect it would and maybe, perhaps with parenthesization, easy to define without ambiguity. (A directional Foo with element type Foo could be tricky.)

Reported on twitter.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions