main is the entry point for the program.
()
| 16 | |
| 17 | // main is the entry point for the program. |
| 18 | func 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. |
nothing calls this directly
no test coverage detected