-
Notifications
You must be signed in to change notification settings - Fork 7
/
main.go
58 lines (49 loc) · 912 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package main
import(
"fmt"
"net/url"
"bufio"
"os"
"sync"
"flag"
)
func main() {
var s bool
var multi bool
flag.BoolVar(&s, "s" , false , "For a single parameter")
flag.BoolVar(&multi, "m" , false, "For mutliple parameters")
flag.Parse()
var urls []string
sc := bufio.NewScanner(os.Stdin)
for sc.Scan() {
urls = append(urls, sc.Text())
}
if err := sc.Err(); err != nil {
fmt.Fprintf(os.Stderr, "failed to read input: %s\n")
}
results := make(chan string)
var wg sync.WaitGroup
for _, link := range urls {
wg.Add(1)
go func(link string) {
u , err := url.Parse(link)
if err != nil {
fmt.Println(err)
}
if multi == true {
fmt.Println(u.RawQuery)
}
if s == true {
m, err := url.ParseQuery(u.RawQuery)
if err == nil {
for k := range m {
fmt.Println(k)
}
}
}
defer wg.Done()
}(link)
}
wg.Wait()
close(results)
}