-
Notifications
You must be signed in to change notification settings - Fork 0
/
result.go
45 lines (36 loc) · 797 Bytes
/
result.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
package main
import (
"fmt"
"time"
)
type location struct {
URL string
Referrer string
}
func (l location) String() string {
if len(l.Referrer) == 0 {
return l.URL
}
return fmt.Sprintf("%s (ref %s)", l.URL, l.Referrer)
}
type update struct {
Location location
Skipped bool
Error error
Status int
ResponseTime time.Duration
ContentType string
Links []string
}
func (u update) String() string {
if u.Error != nil {
return fmt.Sprintf("[ERR] %s (%s; %s)", u.Location, u.ResponseTime, u.Error)
}
if u.Skipped {
return fmt.Sprintf("[SKP] %s", u.Location)
}
return fmt.Sprintf("[%03d] %s (%s; %d links)", u.Status, u.Location, u.ResponseTime, len(u.Links))
}
func (u update) IsOK() bool {
return u.Status >= 200 && u.Status <= 299
}