Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

Commit

Permalink
Add missing Wait() and fix memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
lc committed May 16, 2020
1 parent a9b6bc6 commit 2aeaa83
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions runner/subjs/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/PuerkitoBio/goquery"
)

const version = `1.0.0`
const version = `1.0.1`

type SubJS struct {
client *http.Client
Expand All @@ -41,6 +41,7 @@ func (s *SubJS) Run() error {
if err != nil {
return fmt.Errorf("Could not open input file: %s", err)
}
defer input.Close()
}

// init channels
Expand All @@ -60,10 +61,10 @@ func (s *SubJS) Run() error {
var out sync.WaitGroup
out.Add(1)
go func() {
defer out.Done()
for result := range results {
fmt.Println(result)
}
out.Done()
}()
scan := bufio.NewScanner(input)
for scan.Scan() {
Expand All @@ -75,6 +76,7 @@ func (s *SubJS) Run() error {
close(urls)
w.Wait()
close(results)
out.Wait()
return nil
}
func (s *SubJS) fetch(urls <-chan string, results chan string) {
Expand Down

0 comments on commit 2aeaa83

Please sign in to comment.