...

Source file src/cmd/compile/internal/types2/chan.go

Documentation: cmd/compile/internal/types2

     1  // Copyright 2011 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package types2
     6  
     7  // A Chan represents a channel type.
     8  type Chan struct {
     9  	dir  ChanDir
    10  	elem Type
    11  }
    12  
    13  // A ChanDir value indicates a channel direction.
    14  type ChanDir int
    15  
    16  // The direction of a channel is indicated by one of these constants.
    17  const (
    18  	SendRecv ChanDir = iota
    19  	SendOnly
    20  	RecvOnly
    21  )
    22  
    23  // NewChan returns a new channel type for the given direction and element type.
    24  func NewChan(dir ChanDir, elem Type) *Chan {
    25  	return &Chan{dir: dir, elem: elem}
    26  }
    27  
    28  // Dir returns the direction of channel c.
    29  func (c *Chan) Dir() ChanDir { return c.dir }
    30  
    31  // Elem returns the element type of channel c.
    32  func (c *Chan) Elem() Type { return c.elem }
    33  
    34  func (c *Chan) Underlying() Type { return c }
    35  func (c *Chan) String() string   { return TypeString(c, nil) }
    36  

View as plain text