Filter applies options to filter URLs from the input channel.
(input <-chan url.URL, options ...func([]url.URL) []url.URL)
| 69 | |
| 70 | // Filter applies options to filter URLs from the input channel. |
| 71 | func Filter(input <-chan url.URL, options ...func([]url.URL) []url.URL) (<-chan url.URL, error) { |
| 72 | output := make(chan url.URL) |
| 73 | go func() { |
| 74 | defer close(output) |
| 75 | var urls []url.URL |
| 76 | for u := range input { |
| 77 | urls = append(urls, u) |
| 78 | } |
| 79 | |
| 80 | for _, option := range options { |
| 81 | urls = option(urls) |
| 82 | } |
| 83 | |
| 84 | for _, u := range urls { |
| 85 | output <- u |
| 86 | } |
| 87 | }() |
| 88 | return output, nil |
| 89 | } |
| 90 | |
| 91 | // WithComplete is an option to complete relative URLs. |
| 92 | func WithComplete(base *url.URL) func([]url.URL) []url.URL { |
no outgoing calls
no test coverage detected