为什么该程序产生输出

I am new to GO from google. In buffered channels here is a program:

package main

import "fmt"
import "time"

func main() {
    c := make(chan int, 2)
    c <- 1
    fmt.Println(<-c)
    time.Sleep(1000 * time.Millisecond)
    c <- 2    
    fmt.Println(<-c)
}

It produces output. But according to http://tour.golang.org/#64 it says:

Sends to a buffered channel block only when the buffer is full. Receives block when the buffer is empty.

As it says it send only when FULL why does the program produce an output instead of waiting infinity for c to full up at the first statement. ?

Your channel has a buffer size of two. You're putting one int in then pulling one int out. Then you sleep and repeat the process. The channel will not block until you try to insert a third int without pulling any ints out. The first two ints will be buffered.

I guess you didn't understood the slide properly. It says "block only" you understood "work only".

What the slide said is:

  • If the buffer is not full, then your send will work properly and it won't block

  • If the buffer is full, then your send will block until the buffer is not full.

So your example is working as specified.