File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99 "log"
1010 "net/http"
1111 "os"
12+ "sync"
1213 "time"
1314)
1415
@@ -78,27 +79,30 @@ func main() {
7879 }
7980
8081 var allHistoryUrls []string
81- historicResponses := make (chan []byte )
82+ var wg sync.WaitGroup
83+ historicResponses := make ([][]byte , len (historyItems ))
8284 for i , hi := range historyItems {
8385 historyUrl := fmt .Sprintf ("https://web.archive.org/web/%vif_/%v" , hi .Timestamp , * url )
8486
8587 if * printUrls {
8688 allHistoryUrls = append (allHistoryUrls , historyUrl )
8789 continue
88- return
8990 }
9091
92+ wg .Add (1 )
9193 if i % MAX_REQUESTS_COUNT == 0 {
9294 time .Sleep (PAUSE_INTERVAL * time .Second )
9395 }
9496
9597 go func () {
96- historicResponses <- get (historyUrl )
98+ historicResponses = append (historicResponses , get (historyUrl ))
99+ wg .Done ()
97100 }()
98101 }
102+ wg .Wait ()
99103
100104 uniqueResponses := make (map [[20 ]byte ][]byte )
101- for res := range historicResponses {
105+ for _ , res := range historicResponses {
102106 if * output != "" || * unique {
103107 uniqueResponses [sha1 .Sum (res )] = res
104108 }
You can’t perform that action at this time.
0 commit comments