MCPcopy Create free account
hub / github.com/goinaction/code / main

Function main

chapter7/patterns/runner/main/main.go:18–40  ·  view source on GitHub ↗

main is the entry point for the program.

()

Source from the content-addressed store, hash-verified

16
17// main is the entry point for the program.
18func main() {
19 log.Println("Starting work.")
20
21 // Create a new timer value for this run.
22 r := runner.New(timeout)
23
24 // Add the tasks to be run.
25 r.Add(createTask(), createTask(), createTask())
26
27 // Run the tasks and handle the result.
28 if err := r.Start(); err != nil {
29 switch err {
30 case runner.ErrTimeout:
31 log.Println("Terminating due to timeout.")
32 os.Exit(1)
33 case runner.ErrInterrupt:
34 log.Println("Terminating due to interrupt.")
35 os.Exit(2)
36 }
37 }
38
39 log.Println("Process ended.")
40}
41
42// createTask returns an example task that sleeps for the specified
43// number of seconds based on the id.

Callers

nothing calls this directly

Calls 3

createTaskFunction · 0.85
AddMethod · 0.80
StartMethod · 0.80

Tested by

no test coverage detected