Skip to content

Commit

Permalink
fix(panic): fix output panic
Browse files Browse the repository at this point in the history
  • Loading branch information
lc committed Nov 2, 2023
1 parent 0db165c commit c146c22
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions cmd/gau/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,28 +31,26 @@ func main() {

results := make(chan string)

var out io.Writer
var out = os.Stdout
// Handle results in background
if config.Output != "" {
out, err := os.OpenFile(config.Output, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
out, err = os.OpenFile(config.Output, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
log.Fatalf("Could not open output file: %v\n", err)
}
defer out.Close()
} else {
out = os.Stdout
}

writeWg := new(sync.WaitGroup)
var writeWg sync.WaitGroup
writeWg.Add(1)
go func(JSON bool) {
go func(out io.Writer, JSON bool) {
defer writeWg.Done()
if JSON {
output.WriteURLsJSON(out, results, config.Blacklist, config.RemoveParameters)
} else if err = output.WriteURLs(out, results, config.Blacklist, config.RemoveParameters); err != nil {
log.Fatalf("error writing results: %v\n", err)
}
}(config.JSON)
}(out, config.JSON)

workChan := make(chan runner.Work)
gau.Start(workChan, results)
Expand Down

0 comments on commit c146c22

Please sign in to comment.