Skip to content

Instantly share code, notes, and snippets.

@sugilog sugilog/sample.go
Created Jan 24, 2015

Embed
What would you like to do?
バッファ
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
You can’t perform that action at this time.