Goroutines

A goroutine is a lightweight thread of execution managed by the Go runtime. To start a new goroutine we use the go keyword go f(x, y, z) The evaluation of f, x, y, and z happens in the current goroutine and the execution of f happens in the new goroutine. Goroutines run in the same address space, so access to shared memory must be synchronized. The sync package provides useful primitives, although you won’t need them much in Go as there are other primitives like channels....

December 24, 2023 · 4 min · 843 words · Lakshya Singh