| --- |
| title: InvalidChanAssign |
| layout: article |
| --- |
| <!-- Copyright 2023 The Go Authors. All rights reserved. |
| Use of this source code is governed by a BSD-style |
| license that can be found in the LICENSE file. --> |
| |
| <!-- Code generated by generrordocs.go; DO NOT EDIT. --> |
| |
| ``` |
| InvalidChanAssign occurs when a chan assignment is invalid. |
| |
| Per the spec, a value x is assignable to a channel type T if: |
| "x is a bidirectional channel value, T is a channel type, x's type V and |
| T have identical element types, and at least one of V or T is not a |
| defined type." |
| |
| Example: |
| type T1 chan int |
| type T2 chan int |
| |
| var x T1 |
| // Invalid assignment because both types are named |
| var _ T2 = x |
| ``` |
| |