-
Notifications
You must be signed in to change notification settings - Fork 1
/
utils.go
39 lines (32 loc) · 845 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
package main
import (
"fmt"
"os"
"time"
)
// debug displays only if fDebug is set
func debug(str string, a ...interface{}) {
if fDebug {
fmt.Fprintf(os.Stderr, str, a...)
}
}
// verbose displays only if fVerbose is set
func verbose(str string, a ...interface{}) {
if fVerbose {
fmt.Printf(str, a...)
}
}
// fatalf is like log.Fatalf()
func fatalf(str string, a ...interface{}) {
fmt.Fprintf(os.Stderr, str, a...)
os.Exit(1)
}
// makeDate for month tagging.
func makeDate() string {
return time.Now().Format("2006-01") + "-01"
}
// ByAlphabet is for sorting
type ByAlphabet TLSReport
func (a ByAlphabet) Len() int { return len(a.Sites) }
func (a ByAlphabet) Swap(i, j int) { a.Sites[i], a.Sites[j] = a.Sites[j], a.Sites[i] }
func (a ByAlphabet) Less(i, j int) bool { return a.Sites[i].Name < a.Sites[j].Name }