Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@sugilog
Created January 24, 2015 16:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sugilog/a4300c516e5d4cf8d236 to your computer and use it in GitHub Desktop.
Save sugilog/a4300c516e5d4cf8d236 to your computer and use it in GitHub Desktop.
バッファ
package main
import (
"fmt"
)
func main() {
channel := make( chan int, 2 )
fmt.Println( "before send" )
fmt.Println( len( channel ) )
fmt.Println( cap( channel ) )
channel <- 1
channel <- 2
// channel <- 3
fmt.Println( "after send" )
fmt.Println( len( channel ) )
fmt.Println( cap( channel ) )
fmt.Println( "received value" )
fmt.Println( <- channel )
fmt.Println( <- channel )
// fmt.Println( <- channel )
fmt.Println( "after receive" )
fmt.Println( len( channel ) )
fmt.Println( cap( channel ) )
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment