File tree Expand file tree Collapse file tree 1 file changed +11
-11
lines changed Expand file tree Collapse file tree 1 file changed +11
-11
lines changed Original file line number Diff line number Diff line change @@ -80,7 +80,16 @@ func (c *Client) checkURLs(urls []string) {
80
80
ch := make (chan string )
81
81
82
82
for i := 0 ; i < workerCount ; i ++ {
83
- go c .checkURL (ch )
83
+ go func (urls chan string ) {
84
+ for {
85
+ u , ok := <- urls
86
+ if ! ok {
87
+ break
88
+ }
89
+
90
+ c .checkURL (u )
91
+ }
92
+ }(ch )
84
93
}
85
94
86
95
for _ , url := range urls {
@@ -89,13 +98,7 @@ func (c *Client) checkURLs(urls []string) {
89
98
close (ch )
90
99
}
91
100
92
- func (c * Client ) checkURL (urls chan string ) {
93
- for {
94
- u , ok := <- urls
95
- if ! ok {
96
- return
97
- }
98
-
101
+ func (c * Client ) checkURL (u string ) {
99
102
resp , err := c .client .Head (u )
100
103
if err != nil {
101
104
if _ , ok := err .(* url.Error ); ok {
@@ -104,8 +107,6 @@ func (c *Client) checkURL(urls chan string) {
104
107
}
105
108
} else {
106
109
switch resp .StatusCode {
107
- case http .StatusOK :
108
- continue
109
110
case http .StatusNotFound , http .StatusGone :
110
111
log .Printf ("Deleting (404): %s\n " , u )
111
112
c .deleteURL (u )
@@ -114,7 +115,6 @@ func (c *Client) checkURL(urls chan string) {
114
115
}
115
116
}
116
117
}
117
- }
118
118
119
119
func (c * Client ) deleteURL (url string ) {
120
120
if ! c .DryRun {
You can’t perform that action at this time.
0 commit comments