-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.go
48 lines (37 loc) · 797 Bytes
/
utils.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
package main
import (
"fmt"
"os"
"strings"
)
func handleErr(err error) {
if err == nil {
return
}
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
func removeProtocol(domain string) string {
if strings.HasPrefix(domain, "http://") {
domain = strings.TrimPrefix(domain, "http://")
} else if strings.HasPrefix(domain, "https://") {
domain = strings.TrimPrefix(domain, "https://")
}
return domain
}
func newSubdomain(domain string) {
subMu.Lock()
defer subMu.Unlock()
if _, exists := subdomains[domain]; !exists {
subdomains[domain] = struct{}{}
fmt.Fprintln(outFile, domain)
}
}
func newDirectory(domain string) {
dirMu.Lock()
defer dirMu.Unlock()
if _, exists := directories[domain]; !exists {
directories[domain] = struct{}{}
fmt.Fprintln(outFile, domain)
}
}