August 2019
Beginner to intermediate
798 pages
17h 2m
English
This section will present a way to prevent the main() function from ending while it is waiting for its goroutines to finish using the sync package. The logic of the syncGo.go program will be based on create.go, which was presented in the previous section.
The first part of syncGo.go is as follows:
package main
import (
"flag"
"fmt"
"sync"
)
As you can see, there is no need to import and use the time package, as we will use the functionality of the sync package and wait for as long as necessary for all the goroutines to end.
The second code segment of ...
Read now
Unlock full access