progressWorker outputs the progress every tick. It will stop once cancel() is called on the context
(ctx context.Context, g *libgobuster.Gobuster, wg *sync.WaitGroup)
| 109 | // progressWorker outputs the progress every tick. It will stop once cancel() is called |
| 110 | // on the context |
| 111 | func progressWorker(ctx context.Context, g *libgobuster.Gobuster, wg *sync.WaitGroup) { |
| 112 | defer wg.Done() |
| 113 | |
| 114 | tick := time.NewTicker(cliProgressUpdate) |
| 115 | |
| 116 | for { |
| 117 | select { |
| 118 | case <-tick.C: |
| 119 | printProgress(g) |
| 120 | case <-ctx.Done(): |
| 121 | // print the final progress so we end at 100% |
| 122 | printProgress(g) |
| 123 | fmt.Println() // nolint:forbidigo |
| 124 | return |
| 125 | } |
| 126 | } |
| 127 | } |
| 128 | |
| 129 | func writeToFile(f *os.File, output string) error { |
| 130 | _, err := fmt.Fprintf(f, "%s\n", output) |
no test coverage detected