Every time I started to learn a new programming language that supports multi-threading, the “hello world” program to me is vector adding. Vector adding is very simple in logic, and involves almost every fundamental operations that a parallel program would use, such as creating threads, waiting for threads finished, and setting mutex, etc. So, implementing a vector add program in go is a good stepping stone for me to learn how to use goroutine to achieve concurrency.
Before started I did not expect achieving concurrency is that easy in golang. Only one line is needed to create a single thread, compared with how it goes in C++/Python – adding long and clumsy clauses to create threadpool and create threads, that is so easy. Thus I did not pay much effort and get the vector adding program as following.