Let's solve Quizzes about Go Parallelism!!! Become an advanced Gopher!!!

By aimof

Elevator Pitch

Don’t you need a little break? Let’s enjoy quiz with me!! Quiz is fun, so fun.

Quiz Theme is …………. Go Parallelism!!!!

Do you understand Go parallelism correctly? It’s difficult part of Go for beginners. Let’s solve some quizzes and become an advanced Gopher!

Description

Introduction

(package and import part is skipped. I only use standard packages)

```

func main() { for i := 0; i < 5; i++ { go fmt.Println(i) } }

```

Do you know what is occurred when the code is executed? Off course it is a basically quiz so it’s easy to answer.

Print nothing and exit 0

Do you understand this?

If you want to know about Go parallelism more, let’s solve quizzes with me!!

Sammary

One of the feature of go is its parallelism. But it’s difficult for beginners (even though Go parallelism is easier than other languages.) So let’s solve quizzes about go parallelism and become deepen your knowledge.

info

  • Goal: Deepen Our knowledge about go parallelism.
  • Target: Beginners ~ Junior class Go programmer.
  • Theme: Go Parallelism such as Goroutine and channel.
  • Format: Quiz

Enjoy GoCon!

Notes

Even though I’m an junior class Go developer, I’m a quiz entertainer. I’ll surprise, make fun listeners. Don’t you need some enjoyable, relax and interactive talk?

quiz example

This talk is based a Qiita post 鬱陶しいくらい「いいね」するよう勧めてくるgoroutineクイズ about a year ago. (Please ignore this article is joking.) Even though it seems to be a joke I thought hard about this quizzes.

I’ll make quizzes like in this article.

example

Q. What will be occuerd?

```

func main() { ch := make(chan bool) go exit(ch)

time.Sleep(time.Second)
close(ch)
time.Sleep(time.Second)
os.Exit(0) }

func exit(ch chan bool) { v := <-ch if v { fmt.Println(“true”) os.Exit(1) } fmt.Println(“false”) os.Exit(1) }

```

(Sorry, this page doesn’ t seem to support code snipet)

A.

```

false exit status 1

```

closed goroutine send zero-value.