Loading concurrency/concurrency2.go 0 → 100644 +1 −0 Original line number Diff line number Diff line package concurrency concurrency/concurrency2_test.go 0 → 100644 +79 −0 Original line number Diff line number Diff line package concurrency import "testing" func TestConcurrencyBasic001(t *testing.T) { stringStream := make(chan string) close(stringStream) go func() { stringStream <- "Hello from goroutine!" }() salutation, ok := <-stringStream t.Logf("status \"%t\": \"%s\"", ok, salutation) salutation, ok = <-stringStream t.Logf("status \"%t\": \"%s\"", ok, salutation) } func TestConcurrencyBasic002(t *testing.T) { stringStream := make(chan string) defer close(stringStream) go func() { stringStream <- "Hello from goroutine!" }() salutation, ok := <-stringStream t.Logf("status \"%t\": \"%s\"", ok, salutation) salutation, ok = <-stringStream t.Logf("status \"%t\": \"%s\"", ok, salutation) } func TestConcurrencyBasic003(t *testing.T) { stringStream := make(chan string) go func() { defer close(stringStream) stringStream <- "Hello from goroutine!" }() salutation, ok := <-stringStream t.Logf("status \"%t\": \"%s\"", ok, salutation) salutation, ok = <-stringStream t.Logf("status \"%t\": \"%s\"", ok, salutation) } func TestConcurrencyBasic004(t *testing.T) { intStream := make(chan int) go func() { defer close(intStream) for i := 0; i < 10; i++ { intStream <- i } }() for j := range intStream { t.Logf("j: %d", j) } } func TestConcurrencyBasic005(t *testing.T) { } func TestConcurrencyBasic006(t *testing.T) { } func TestConcurrencyBasic007(t *testing.T) { } func TestConcurrencyBasic008(t *testing.T) { } func TestConcurrencyBasic009(t *testing.T) { } func TestConcurrencyBasic010(t *testing.T) { } func TestConcurrencyBasic011(t *testing.T) { } Loading
concurrency/concurrency2.go 0 → 100644 +1 −0 Original line number Diff line number Diff line package concurrency
concurrency/concurrency2_test.go 0 → 100644 +79 −0 Original line number Diff line number Diff line package concurrency import "testing" func TestConcurrencyBasic001(t *testing.T) { stringStream := make(chan string) close(stringStream) go func() { stringStream <- "Hello from goroutine!" }() salutation, ok := <-stringStream t.Logf("status \"%t\": \"%s\"", ok, salutation) salutation, ok = <-stringStream t.Logf("status \"%t\": \"%s\"", ok, salutation) } func TestConcurrencyBasic002(t *testing.T) { stringStream := make(chan string) defer close(stringStream) go func() { stringStream <- "Hello from goroutine!" }() salutation, ok := <-stringStream t.Logf("status \"%t\": \"%s\"", ok, salutation) salutation, ok = <-stringStream t.Logf("status \"%t\": \"%s\"", ok, salutation) } func TestConcurrencyBasic003(t *testing.T) { stringStream := make(chan string) go func() { defer close(stringStream) stringStream <- "Hello from goroutine!" }() salutation, ok := <-stringStream t.Logf("status \"%t\": \"%s\"", ok, salutation) salutation, ok = <-stringStream t.Logf("status \"%t\": \"%s\"", ok, salutation) } func TestConcurrencyBasic004(t *testing.T) { intStream := make(chan int) go func() { defer close(intStream) for i := 0; i < 10; i++ { intStream <- i } }() for j := range intStream { t.Logf("j: %d", j) } } func TestConcurrencyBasic005(t *testing.T) { } func TestConcurrencyBasic006(t *testing.T) { } func TestConcurrencyBasic007(t *testing.T) { } func TestConcurrencyBasic008(t *testing.T) { } func TestConcurrencyBasic009(t *testing.T) { } func TestConcurrencyBasic010(t *testing.T) { } func TestConcurrencyBasic011(t *testing.T) { }